Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jobs:
checks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: 3.8
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 30 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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))
9 changes: 5 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down