Skip to content

Commit ff4789f

Browse files
authored
[tests] add Python 3.10 env, update pytest dependency (#30)
1 parent 4b8580f commit ff4789f

File tree

5 files changed

+39
-11
lines changed

5 files changed

+39
-11
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ jobs:
55
checks:
66
runs-on: ubuntu-latest
77
strategy:
8+
fail-fast: false
89
matrix:
910
include:
1011
- python-version: 3.8

.github/workflows/tests.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ jobs:
55
tests:
66
runs-on: ${{ matrix.os }}
77
strategy:
8+
fail-fast: false
89
matrix:
910
os: [ubuntu-latest, macos-10.15]
10-
python-version: [3.7, 3.8, 3.9]
11+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1112

1213
steps:
1314
- uses: actions/checkout@v2
@@ -20,11 +21,6 @@ jobs:
2021
- name: Install tox
2122
run: pip install tox
2223

23-
- name: Install playwright & browsers
24-
run: |
25-
pip install playwright
26-
python -m playwright install
27-
2824
- name: Run tests
2925
run: tox -e py
3026

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
url="https://github.com/scrapy-plugins/scrapy-playwright",
2020
packages=["scrapy_playwright"],
2121
classifiers=[
22-
"Development Status :: 1 - Planning",
22+
"Development Status :: 3 - Alpha",
2323
"License :: OSI Approved :: BSD License",
2424
"Programming Language :: Python",
2525
"Programming Language :: Python :: 3.7",
2626
"Programming Language :: Python :: 3.8",
2727
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
2829
"Framework :: Scrapy",
2930
"Intended Audience :: Developers",
3031
"Topic :: Internet :: WWW/HTTP",

tests/conftest.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
Taken from
3+
https://github.com/pytest-dev/pytest-asyncio/blob/25cf2b399e00a82b69951474eed074ba26cd0c3b/pytest_asyncio/plugin.py
4+
5+
Modify pytest_pycollect_makeitem to make use of the Function API
6+
in pytest>=5.4.0 (pytest.Function.from_parent).
7+
8+
In the context of scrapy-playwright, this allows to unpin the outdated pytest<5.4.0 dependency,
9+
while keeping pytest-asyncio==0.10, as pytest-asyncio>=0.11 currently breaks tests.
10+
"""
11+
12+
13+
import asyncio
14+
import inspect
15+
16+
import pytest
17+
18+
19+
def _is_coroutine(obj):
20+
"""Check to see if an object is really an asyncio coroutine."""
21+
return asyncio.iscoroutinefunction(obj) or inspect.isgeneratorfunction(obj)
22+
23+
24+
@pytest.mark.tryfirst
25+
def pytest_pycollect_makeitem(collector, name, obj):
26+
"""A pytest hook to collect asyncio coroutines."""
27+
if collector.funcnamefilter(name) and _is_coroutine(obj):
28+
item = pytest.Function.from_parent(collector, name=name)
29+
if "asyncio" in item.keywords:
30+
return list(collector._genfunctions(name, obj))

tox.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ envlist = bandit,black,flake8,typing,py
55
deps =
66
playwright>=1.8.0a1
77
scrapy>=2.0,!=2.4.0
8-
pytest<5.4
9-
pytest-asyncio<0.11
10-
pytest-cov>=2.8
11-
pytest-twisted>=1.11
8+
pytest==6.2.5
9+
pytest-asyncio==0.10
10+
pytest-cov==3.0.0
11+
pytest-twisted==1.13.4
1212
commands =
1313
playwright install
1414
py.test --reactor=asyncio \

0 commit comments

Comments
 (0)