From 75f1a0dc79a1a40b8e9d22cfb925542cc4d8a446 Mon Sep 17 00:00:00 2001 From: Chris Ostrouchov Date: Fri, 28 Feb 2020 14:11:46 -0500 Subject: [PATCH 1/6] Remove RemovedInPytest4Warning resolved in latest pytest Resolved with issues: https://github.com/pytest-dev/pytest/issues/4039 --- pytest_trio/_tests/conftest.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pytest_trio/_tests/conftest.py b/pytest_trio/_tests/conftest.py index 7e1ccd9..c6481d5 100644 --- a/pytest_trio/_tests/conftest.py +++ b/pytest_trio/_tests/conftest.py @@ -1,11 +1 @@ -# Temporary hack while waiting for an answer here: -# https://github.com/pytest-dev/pytest/issues/4039 -import pytest -import warnings -warnings.filterwarnings( - "default", - category=pytest.RemovedInPytest4Warning, - message=".*non-top-level conftest.*", -) - pytest_plugins = ["pytester"] From f14615e7b986fc602c6a66f18dca6f0bae061b1f Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 11 Mar 2020 17:16:45 +0400 Subject: [PATCH 2/6] ci: bump tested Python versions --- .travis.yml | 29 ++++++++++++++++++++--------- ci/travis.sh | 39 +-------------------------------------- 2 files changed, 21 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index c37a900..d4410cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,23 @@ +os: linux +dist: bionic language: python python: -- 3.5.0 -- 3.5.2 +- pypy3.6-7.2.0 - 3.5-dev - 3.6 - 3.6-dev +- 3.7 - 3.7-dev -sudo: false -dist: trusty -matrix: +- 3.8 +- 3.8-dev +jobs: include: - - os: linux - language: generic - env: USE_PYPY_RELEASE_VERSION=5.9-beta + - python: 3.5.0 + dist: trusty + # The last pytest to support Python 3.5.2 fails to start with recent attrs + # - python: 3.5.2 + # dist: trusty + # Python3.5 on MacOS doesn't currently support TLSv1.2 needed to use pip :( # http://pyfound.blogspot.fr/2017/01/time-to-upgrade-your-python-tls-v12.html # - os: osx @@ -20,7 +25,13 @@ matrix: # env: MACPYTHON=3.5.4 - os: osx language: generic - env: MACPYTHON=3.6.3 + env: MACPYTHON=3.6.8 + - os: osx + language: generic + env: MACPYTHON=3.7.7 + - os: osx + language: generic + env: MACPYTHON=3.8.1 - os: linux language: python python: 3.6 diff --git a/ci/travis.sh b/ci/travis.sh index 6cee6a7..d904d39 100755 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -6,7 +6,7 @@ set -ex YAPF_VERSION=0.22.0 if [ "$TRAVIS_OS_NAME" = "osx" ]; then - curl -Lo macpython.pkg https://www.python.org/ftp/python/${MACPYTHON}/python-${MACPYTHON}-macosx10.6.pkg + curl -Lo macpython.pkg https://www.python.org/ftp/python/${MACPYTHON}/python-${MACPYTHON}-macosx10.9.pkg sudo installer -pkg macpython.pkg -target / ls /Library/Frameworks/Python.framework/Versions/*/bin/ PYTHON_EXE=/Library/Frameworks/Python.framework/Versions/*/bin/python3 @@ -15,43 +15,6 @@ if [ "$TRAVIS_OS_NAME" = "osx" ]; then source testenv/bin/activate fi -if [ "$USE_PYPY_NIGHTLY" = "1" ]; then - curl -fLo pypy.tar.bz2 http://buildbot.pypy.org/nightly/py3.5/pypy-c-jit-latest-linux64.tar.bz2 - if [ ! -s pypy.tar.bz2 ]; then - # We know: - # - curl succeeded (200 response code; -f means "exit with error if - # server returns 4xx or 5xx") - # - nonetheless, pypy.tar.bz2 does not exist, or contains no data - # This isn't going to work, and the failure is not informative of - # anything involving this package. - ls -l - echo "PyPy3 nightly build failed to download – something is wrong on their end." - echo "Skipping testing against the nightly build for right now." - exit 0 - fi - tar xaf pypy.tar.bz2 - # something like "pypy-c-jit-89963-748aa3022295-linux64" - PYPY_DIR=$(echo pypy-c-jit-*) - PYTHON_EXE=$PYPY_DIR/bin/pypy3 - ($PYTHON_EXE -m ensurepip \ - && $PYTHON_EXE -m pip install virtualenv \ - && $PYTHON_EXE -m virtualenv testenv) \ - || (echo "pypy nightly is broken; skipping tests"; exit 0) - source testenv/bin/activate -fi - -if [ "$USE_PYPY_RELEASE_VERSION" != "" ]; then - curl -fLo pypy.tar.bz2 https://bitbucket.org/squeaky/portable-pypy/downloads/pypy3.5-${USE_PYPY_RELEASE_VERSION}-linux_x86_64-portable.tar.bz2 - tar xaf pypy.tar.bz2 - # something like "pypy3.5-5.7.1-beta-linux_x86_64-portable" - PYPY_DIR=$(echo pypy3.5-*) - PYTHON_EXE=$PYPY_DIR/bin/pypy3 - $PYTHON_EXE -m ensurepip - $PYTHON_EXE -m pip install virtualenv - $PYTHON_EXE -m virtualenv testenv - source testenv/bin/activate -fi - pip install -U pip setuptools wheel if [ "$CHECK_FORMATTING" = "1" ]; then From 43668c26430d66b4f8dfc7ac6a5aeb0a03fb860d Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 19 May 2020 21:03:15 +0400 Subject: [PATCH 3/6] Stop testing Python 3.5 --- .appveyor.yml | 6 ++++-- .travis.yml | 12 ------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 1ebc291..29dd725 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,10 +4,12 @@ os: Visual Studio 2015 environment: matrix: - - PYTHON: "C:\\Python35" - - PYTHON: "C:\\Python35-x64" - PYTHON: "C:\\Python36" - PYTHON: "C:\\Python36-x64" + - PYTHON: "C:\\Python37" + - PYTHON: "C:\\Python37-x64" + - PYTHON: "C:\\Python38" + - PYTHON: "C:\\Python38-x64" build_script: - "git --no-pager log -n2" diff --git a/.travis.yml b/.travis.yml index d4410cc..c5fd788 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ dist: bionic language: python python: - pypy3.6-7.2.0 -- 3.5-dev - 3.6 - 3.6-dev - 3.7 @@ -12,17 +11,6 @@ python: - 3.8-dev jobs: include: - - python: 3.5.0 - dist: trusty - # The last pytest to support Python 3.5.2 fails to start with recent attrs - # - python: 3.5.2 - # dist: trusty - - # Python3.5 on MacOS doesn't currently support TLSv1.2 needed to use pip :( - # http://pyfound.blogspot.fr/2017/01/time-to-upgrade-your-python-tls-v12.html - # - os: osx - # language: generic - # env: MACPYTHON=3.5.4 - os: osx language: generic env: MACPYTHON=3.6.8 From 9572aaff6010aad79280950392d56155949203d5 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Tue, 19 May 2020 21:06:34 +0400 Subject: [PATCH 4/6] Fix compatibility with Trio 0.15.0 --- pytest_trio/_tests/test_fixture_names.py | 2 +- pytest_trio/plugin.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pytest_trio/_tests/test_fixture_names.py b/pytest_trio/_tests/test_fixture_names.py index f22f64e..54c531c 100644 --- a/pytest_trio/_tests/test_fixture_names.py +++ b/pytest_trio/_tests/test_fixture_names.py @@ -12,7 +12,7 @@ def fixture_with_unique_name(nursery): async def test_fixture_names(fixture_with_unique_name): # This might be a bit fragile ... if we rearrange the nursery hierarchy # somehow so it breaks, then we can make it more robust. - task = trio.hazmat.current_task() + task = trio.lowlevel.current_task() assert task.name == "" sibling_names = {task.name for task in task.parent_nursery.child_tasks} assert "" in sibling_names diff --git a/pytest_trio/plugin.py b/pytest_trio/plugin.py index 5f96cce..4901e49 100644 --- a/pytest_trio/plugin.py +++ b/pytest_trio/plugin.py @@ -208,7 +208,7 @@ async def run(self, test_ctx, contextvars_ctx): # This is a gross hack. I guess Trio should provide a context= # argument to start_soon/start? - task = trio.hazmat.current_task() + task = trio.lowlevel.current_task() assert canary not in task.context task.context = contextvars_ctx # Force a yield so we pick up the new context diff --git a/setup.py b/setup.py index 56221b2..f6798c2 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ packages=find_packages(), entry_points={'pytest11': ['trio = pytest_trio.plugin']}, install_requires=[ - "trio >= 0.11", + "trio >= 0.15.0", "async_generator >= 1.9", "outcome", # For node.get_closest_marker From 4f12e750dc019a6d6156b003a03f5642424b4dfb Mon Sep 17 00:00:00 2001 From: Joshua Oreman Date: Wed, 20 May 2020 01:15:06 +0000 Subject: [PATCH 5/6] Remove trio-asyncio test --- pytest_trio/_tests/test_trio_asyncio.py | 51 ------------------------- test-requirements.txt | 1 - 2 files changed, 52 deletions(-) delete mode 100644 pytest_trio/_tests/test_trio_asyncio.py diff --git a/pytest_trio/_tests/test_trio_asyncio.py b/pytest_trio/_tests/test_trio_asyncio.py deleted file mode 100644 index 8a3d9d0..0000000 --- a/pytest_trio/_tests/test_trio_asyncio.py +++ /dev/null @@ -1,51 +0,0 @@ -import pytest -import sys -import asyncio -from async_generator import async_generator, yield_ - -try: - import trio_asyncio -except ImportError: - pytestmark = pytest.mark.skip(reason="trio-asyncio not available") - - -async def use_asyncio(): - await trio_asyncio.aio_as_trio(asyncio.sleep)(0) - - -@pytest.fixture() -@async_generator -async def asyncio_loop(): - async with trio_asyncio.open_loop() as loop: - await yield_(loop) - - -@pytest.fixture() -@async_generator -async def asyncio_fixture_with_fixtured_loop(asyncio_loop): - await use_asyncio() - await yield_() - - -@pytest.fixture() -@async_generator -async def asyncio_fixture_own_loop(): - async with trio_asyncio.open_loop(): - await use_asyncio() - await yield_() - - -@pytest.mark.trio -async def test_no_fixture(): - async with trio_asyncio.open_loop(): - await use_asyncio() - - -@pytest.mark.trio -async def test_half_fixtured_asyncpg_conn(asyncio_fixture_own_loop): - await use_asyncio() - - -@pytest.mark.trio -async def test_fixtured_asyncpg_conn(asyncio_fixture_with_fixtured_loop): - await use_asyncio() diff --git a/test-requirements.txt b/test-requirements.txt index af55c2c..b2be0f9 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,3 @@ pytest !=3.7.0, !=3.7.1 # https://github.com/python-trio/pytest-trio/pull/50#issuecomment-413124393 pytest-cov hypothesis>=3.64 -trio-asyncio; python_version >= "3.5.3" From 6dfb7684c0fb961bae6b99e566fee27097c5b1d8 Mon Sep 17 00:00:00 2001 From: Joshua Oreman Date: Wed, 20 May 2020 01:38:59 +0000 Subject: [PATCH 6/6] Attempt to fix coverage --- ci/travis.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/travis.sh b/ci/travis.sh index d904d39..cc4b0cd 100755 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -55,7 +55,9 @@ else mkdir empty cd empty - pytest + # These environment variables ensure that the import of the pytest-trio plugin is covered + # even if pytest-trio is loaded before pytest-cov. See https://pytest-cov.readthedocs.io/en/latest/plugins.html + env COV_CORE_SOURCE=pytest_trio COV_CORE_CONFIG=.coveragerc COV_CORE_DATAFILE=.coverage pytest bash <(curl -s https://codecov.io/bash) fi