diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8e1ae933..8dd82d77 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -5,6 +5,7 @@ jobs: checks: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: include: - python-version: 3.8 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 099067f9..6b2fc98f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,9 +5,10 @@ jobs: tests: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-latest, macos-10.15] - python-version: [3.7, 3.8, 3.9] + python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 @@ -20,11 +21,6 @@ jobs: - name: Install tox run: pip install tox - - name: Install playwright & browsers - run: | - pip install playwright - python -m playwright install - - name: Run tests run: tox -e py diff --git a/setup.py b/setup.py index da669f4d..4d278af6 100644 --- a/setup.py +++ b/setup.py @@ -19,12 +19,13 @@ url="https://github.com/scrapy-plugins/scrapy-playwright", packages=["scrapy_playwright"], classifiers=[ - "Development Status :: 1 - Planning", + "Development Status :: 3 - Alpha", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Framework :: Scrapy", "Intended Audience :: Developers", "Topic :: Internet :: WWW/HTTP", diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..7ab80791 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,30 @@ +""" +Taken from +https://github.com/pytest-dev/pytest-asyncio/blob/25cf2b399e00a82b69951474eed074ba26cd0c3b/pytest_asyncio/plugin.py + +Modify pytest_pycollect_makeitem to make use of the Function API +in pytest>=5.4.0 (pytest.Function.from_parent). + +In the context of scrapy-playwright, this allows to unpin the outdated pytest<5.4.0 dependency, +while keeping pytest-asyncio==0.10, as pytest-asyncio>=0.11 currently breaks tests. +""" + + +import asyncio +import inspect + +import pytest + + +def _is_coroutine(obj): + """Check to see if an object is really an asyncio coroutine.""" + return asyncio.iscoroutinefunction(obj) or inspect.isgeneratorfunction(obj) + + +@pytest.mark.tryfirst +def pytest_pycollect_makeitem(collector, name, obj): + """A pytest hook to collect asyncio coroutines.""" + if collector.funcnamefilter(name) and _is_coroutine(obj): + item = pytest.Function.from_parent(collector, name=name) + if "asyncio" in item.keywords: + return list(collector._genfunctions(name, obj)) diff --git a/tox.ini b/tox.ini index 608686c4..c9f8ac6e 100644 --- a/tox.ini +++ b/tox.ini @@ -5,11 +5,12 @@ envlist = bandit,black,flake8,typing,py deps = playwright>=1.8.0a1 scrapy>=2.0,!=2.4.0 - pytest<5.4 - pytest-asyncio<0.11 - pytest-cov>=2.8 - pytest-twisted>=1.11 + pytest==6.2.5 + pytest-asyncio==0.10 + pytest-cov==3.0.0 + pytest-twisted==1.13.4 commands = + playwright install py.test --reactor=asyncio \ --cov-report=term-missing --cov-report=html --cov-report=xml \ --cov=scrapy_playwright {posargs: scrapy_playwright tests}