Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pytest-asyncio for openSUSE:Factory checked in at 2021-07-10 22:54:00 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-asyncio (Old) and /work/SRC/openSUSE:Factory/.python-pytest-asyncio.new.2625 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-asyncio" Sat Jul 10 22:54:00 2021 rev:7 rq:904060 version:0.15.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-asyncio/python-pytest-asyncio.changes 2020-06-30 21:54:48.810452206 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-asyncio.new.2625/python-pytest-asyncio.changes 2021-07-10 22:54:11.807900104 +0200 @@ -1,0 +2,21 @@ +Mon Jul 5 08:38:37 UTC 2021 - Antonio Larrosa <alarr...@suse.com> + +- Add patch to revert a change in 0.15.1 that removed + async_generator support in upstream together with python 3.5 + support. This revert is needed by python-fakeredis 1.5.2 + * 0001-removed-support-for-python-3.5.patch + +------------------------------------------------------------------- +Thu Jun 3 09:53:19 UTC 2021 - Antonio Larrosa <alarr...@suse.com> + +- Update to 0.15.1 + * Hotfix for errors while closing event loops while replacing + them. #209 #210 +- Update to 0.15.0 + * Add support for Python 3.9 + * Abandon support for Python 3.5. If you still require support + for Python 3.5, please use pytest-asyncio v0.14 or earlier. + * Set unused_tcp_port_factory fixture scope to 'session'. #163 + * Properly close event loops when replacing them. #208 + +------------------------------------------------------------------- Old: ---- pytest-asyncio-0.14.0.tar.gz New: ---- 0001-removed-support-for-python-3.5.patch pytest-asyncio-0.15.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-asyncio.spec ++++++ --- /var/tmp/diff_new_pack.nF44Pe/_old 2021-07-10 22:54:12.355895875 +0200 +++ /var/tmp/diff_new_pack.nF44Pe/_new 2021-07-10 22:54:12.359895845 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-pytest-asyncio # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,12 +19,13 @@ %define skip_python2 1 %{?!python_module:%define python_module() python3-%{**}} Name: python-pytest-asyncio -Version: 0.14.0 +Version: 0.15.1 Release: 0 Summary: Pytest support for asyncio License: Apache-2.0 URL: https://github.com/pytest-dev/pytest-asyncio Source: https://github.com/pytest-dev/pytest-asyncio/archive/v%{version}.tar.gz#/pytest-asyncio-%{version}.tar.gz +Patch0: 0001-removed-support-for-python-3.5.patch BuildRequires: %{python_module async_generator >= 1.3} BuildRequires: %{python_module base >= 3.6} BuildRequires: %{python_module hypothesis >= 5.7.1} @@ -46,6 +47,7 @@ %prep %setup -q -n pytest-asyncio-%{version} sed -ie '1i# -*- coding: utf-8 -*-' setup.py +%patch0 -p1 -R %build %python_build ++++++ 0001-removed-support-for-python-3.5.patch ++++++ >From 057562f8aaf9f18d97326a86dbdb9587e866bfe0 Mon Sep 17 00:00:00 2001 From: Michael Seifert <m.seif...@digitalernachschub.de> Date: Tue, 6 Oct 2020 11:00:21 +0200 Subject: [PATCH] feat!: Removed support for Python 3.5. This commit: - Removes Python 3.5 from the tested environments in CI and tox - Removes instructions specific to Python 3.5 from the README - Updates the Changelog - Removes the dependency on async_generator - Removes instructions in conftest that skip certain test cases if the Python version is smaller than 3.6 Signed-off-by: Michael Seifert <m.seif...@digitalernachschub.de> --- .travis.yml | 2 - README.rst | 14 +------ pytest_asyncio/plugin.py | 5 +-- setup.py | 5 +-- .../test_async_gen_fixtures_35.py | 40 ------------------- tests/conftest.py | 6 --- tox.ini | 2 +- 7 files changed, 4 insertions(+), 70 deletions(-) delete mode 100644 tests/async_fixtures/test_async_gen_fixtures_35.py #diff --git a/.travis.yml b/.travis.yml #index db43fef..a19d5d7 100644 #--- a/.travis.yml #+++ b/.travis.yml #@@ -2,8 +2,6 @@ language: python # # matrix: # include: #- - python: 3.5 #- env: TOX_ENV=py35 # - python: 3.6 # env: TOX_ENV=py36 # - python: 3.7 #diff --git a/README.rst b/README.rst #index 64698c6..2f282b5 100644 #--- a/README.rst #+++ b/README.rst #@@ -127,19 +127,6 @@ to redefine the ``event_loop`` fixture to have the same or broader scope. # Async fixtures need the event loop, and so must have the same or narrower scope # than the ``event_loop`` fixture. # #-If you want to do this with Python 3.5, the ``yield`` statement must be replaced with ``await yield_()`` and the coroutine #-function must be decorated with ``@async_generator``, like so: #- #-.. code-block:: python3 #- #- from async_generator import yield_, async_generator #- #- @pytest.fixture #- @async_generator #- async def async_gen_fixture(): #- await asyncio.sleep(0.1) #- await yield_('a value') #- # # Markers # ------- #@@ -178,6 +165,7 @@ Changelog # 0.15.0 (UNRELEASED) # ~~~~~~~~~~~~~~~~~~~ # - Add support for Python 3.9 #+- Abandon support for Python 3.5. If you still require support for Python 3.5, please use pytest-asyncio v0.14 or earlier. # # 0.14.0 (2020-06-24) # ~~~~~~~~~~~~~~~~~~~ diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 2fdc5f4..4b7d6fd 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -13,10 +13,7 @@ def transfer_markers(*args, **kwargs): # noqa pass -try: - from async_generator import isasyncgenfunction -except ImportError: - from inspect import isasyncgenfunction +from inspect import isasyncgenfunction def _is_coroutine(obj): diff --git a/setup.py b/setup.py index ff3855c..2df6fae 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,6 @@ def find_version(): "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", @@ -41,13 +40,11 @@ def find_version(): "Topic :: Software Development :: Testing", "Framework :: Pytest", ], - python_requires=">= 3.5", + python_requires=">= 3.6", install_requires=["pytest >= 5.4.0"], extras_require={ - ':python_version == "3.5"': "async_generator >= 1.3", "testing": [ "coverage", - "async_generator >= 1.3", "hypothesis >= 5.7.1", ], }, #diff --git a/tests/async_fixtures/test_async_gen_fixtures_35.py b/tests/async_fixtures/test_async_gen_fixtures_35.py #deleted file mode 100644 #index 3b552fa..0000000 #--- a/tests/async_fixtures/test_async_gen_fixtures_35.py #+++ /dev/null #@@ -1,40 +0,0 @@ #-import unittest.mock #- #-import pytest #-from async_generator import yield_, async_generator #- #-START = object() #-END = object() #-RETVAL = object() #- #- #-@pytest.fixture(scope='module') #-def mock(): #- return unittest.mock.Mock(return_value=RETVAL) #- #- #-@pytest.fixture #-@async_generator #-async def async_gen_fixture(mock): #- try: #- await yield_(mock(START)) #- except Exception as e: #- mock(e) #- else: #- mock(END) #- #- #-@pytest.mark.asyncio #-async def test_async_gen_fixture(async_gen_fixture, mock): #- assert mock.called #- assert mock.call_args_list[-1] == unittest.mock.call(START) #- assert async_gen_fixture is RETVAL #- #- #-@pytest.mark.asyncio #-async def test_async_gen_fixture_finalized(mock): #- try: #- assert mock.called #- assert mock.call_args_list[-1] == unittest.mock.call(END) #- finally: #- mock.reset_mock() #diff --git a/tests/conftest.py b/tests/conftest.py #index cc2ec16..1ca63fe 100644 #--- a/tests/conftest.py #+++ b/tests/conftest.py #@@ -1,13 +1,7 @@ # import asyncio #-import sys # # import pytest # #-collect_ignore = [] #-if sys.version_info[:2] < (3, 6): #- collect_ignore.append("async_fixtures/test_async_gen_fixtures_36.py") #- collect_ignore.append("async_fixtures/test_nested_36.py") #- # # @pytest.fixture # def dependent_fixture(event_loop): #diff --git a/tox.ini b/tox.ini #index 6cc4a82..f739cc5 100644 #--- a/tox.ini #+++ b/tox.ini #@@ -1,6 +1,6 @@ # [tox] # minversion = 3.14.0 #-envlist = py35, py36, py37, py38, py39 #+envlist = py36, py37, py38, py39 # skip_missing_interpreters = true # # [testenv] ++++++ pytest-asyncio-0.14.0.tar.gz -> pytest-asyncio-0.15.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/.github/workflows/main.yml new/pytest-asyncio-0.15.1/.github/workflows/main.yml --- old/pytest-asyncio-0.14.0/.github/workflows/main.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/.github/workflows/main.yml 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,68 @@ +--- +name: CI + +on: + push: + branches: ["master"] + pull_request: + branches: ["master"] + workflow_dispatch: + +jobs: + tests: + name: "Python ${{ matrix.python-version }}" + runs-on: "ubuntu-latest" + env: + USING_COVERAGE: "3.6,3.7,3.8,3.9" + + strategy: + matrix: + python-version: ["3.6", "3.7", "3.8", "3.9"] + + steps: + - uses: "actions/checkout@v2" + - uses: "actions/setup-python@v2" + with: + python-version: "${{ matrix.python-version }}" + - name: "Install dependencies" + run: | + set -xe + python -VV + python -m site + python -m pip install --upgrade pip wheel + python -m pip install --upgrade coverage[toml] virtualenv tox tox-gh-actions + - name: "Run tox targets for ${{ matrix.python-version }}" + run: "python -m tox" + + # We always use a modern Python version for combining coverage to prevent + # parsing errors in older versions for modern code. + - uses: "actions/setup-python@v2" + with: + python-version: "3.9" + + - name: "Upload coverage to Codecov" + if: "contains(env.USING_COVERAGE, matrix.python-version)" + uses: "codecov/codecov-action@v1" + with: + fail_ci_if_error: true + + package: + name: "Build & verify package" + runs-on: "ubuntu-latest" + + steps: + - uses: "actions/checkout@v2" + - uses: "actions/setup-python@v2" + with: + python-version: "3.9" + + - name: "Install poetry, check-wheel-content, and twine" + run: "python -m pip install wheel twine check-wheel-contents" + - name: "Build package" + run: "python setup.py sdist bdist_wheel" + - name: "List result" + run: "ls -l dist" + - name: "Check wheel contents" + run: "check-wheel-contents dist/*.whl" + - name: "Check long_description" + run: "python -m twine check dist/*" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/.travis.yml new/pytest-asyncio-0.15.1/.travis.yml --- old/pytest-asyncio-0.14.0/.travis.yml 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,20 +0,0 @@ -language: python - -matrix: - include: - - python: 3.5 - env: TOX_ENV=py35 - - python: 3.6 - env: TOX_ENV=py36 - - python: 3.7 - env: TOX_ENV=py37 - - python: 3.8 - env: TOX_ENV=py38 - -install: pip install tox-travis coveralls - -script: tox -e $TOX_ENV - -after_success: - - tox -e coverage-report - - coveralls diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/Makefile new/pytest-asyncio-0.15.1/Makefile --- old/pytest-asyncio-0.14.0/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/Makefile 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,25 @@ +.PHONY: clean clean-build clean-pyc clean-test lint + +clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts + +clean-build: ## remove build artifacts + rm -fr build/ + rm -fr dist/ + rm -fr .eggs/ + find . -name '*.egg-info' -exec rm -fr {} + + find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + find . -name '__pycache__' -exec rm -fr {} + + +clean-test: ## remove test and coverage artifacts + rm -fr .tox/ + rm -f .coverage + rm -fr htmlcov/ + +lint: ## check style with flake8 + flake8 pytest_asyncio tests + black --check --verbose pytest_asyncio tests diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/README.rst new/pytest-asyncio-0.15.1/README.rst --- old/pytest-asyncio-0.14.0/README.rst 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/README.rst 2021-04-22 01:04:04.000000000 +0200 @@ -5,11 +5,13 @@ :target: https://pypi.python.org/pypi/pytest-asyncio .. image:: https://travis-ci.org/pytest-dev/pytest-asyncio.svg?branch=master :target: https://travis-ci.org/pytest-dev/pytest-asyncio -.. image:: https://coveralls.io/repos/pytest-dev/pytest-asyncio/badge.svg - :target: https://coveralls.io/r/pytest-dev/pytest-asyncio +.. image:: https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/master/graph/badge.svg + :target: https://codecov.io/gh/pytest-dev/pytest-asyncio .. image:: https://img.shields.io/pypi/pyversions/pytest-asyncio.svg :target: https://github.com/pytest-dev/pytest-asyncio :alt: Supported Python versions +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/ambv/black pytest-asyncio is an Apache2 licensed library, written in Python, for testing asyncio code with pytest. @@ -127,19 +129,6 @@ Async fixtures need the event loop, and so must have the same or narrower scope than the ``event_loop`` fixture. -If you want to do this with Python 3.5, the ``yield`` statement must be replaced with ``await yield_()`` and the coroutine -function must be decorated with ``@async_generator``, like so: - -.. code-block:: python3 - - from async_generator import yield_, async_generator - - @pytest.fixture - @async_generator - async def async_gen_fixture(): - await asyncio.sleep(0.1) - await yield_('a value') - Markers ------- @@ -175,7 +164,22 @@ Changelog --------- -0.13.0 (2020-06-24) +0.15.1 (2021-04-22) +~~~~~~~~~~~~~~~~~~~ +- Hotfix for errors while closing event loops while replacing them. + `#209 <https://github.com/pytest-dev/pytest-asyncio/issues/209>`_ + `#210 <https://github.com/pytest-dev/pytest-asyncio/issues/210>`_ + +0.15.0 (2021-04-19) +~~~~~~~~~~~~~~~~~~~ +- Add support for Python 3.9 +- Abandon support for Python 3.5. If you still require support for Python 3.5, please use pytest-asyncio v0.14 or earlier. +- Set ``unused_tcp_port_factory`` fixture scope to 'session'. + `#163 <https://github.com/pytest-dev/pytest-asyncio/pull/163>`_ +- Properly close event loops when replacing them. + `#208 <https://github.com/pytest-dev/pytest-asyncio/issues/208>`_ + +0.14.0 (2020-06-24) ~~~~~~~~~~~~~~~~~~~ - Fix `#162 <https://github.com/pytest-dev/pytest-asyncio/issues/162>`_, and ``event_loop`` fixture behavior now is coherent on all scopes. `#164 <https://github.com/pytest-dev/pytest-asyncio/pull/164>`_ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/pytest_asyncio/__init__.py new/pytest-asyncio-0.15.1/pytest_asyncio/__init__.py --- old/pytest-asyncio-0.14.0/pytest_asyncio/__init__.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/pytest_asyncio/__init__.py 2021-04-22 01:04:04.000000000 +0200 @@ -1,2 +1,2 @@ """The main point for importing pytest-asyncio items.""" -__version__ = "0.14.0" +__version__ = "0.15.1" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/pytest_asyncio/plugin.py new/pytest-asyncio-0.15.1/pytest_asyncio/plugin.py --- old/pytest-asyncio-0.14.0/pytest_asyncio/plugin.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/pytest_asyncio/plugin.py 2021-04-22 01:04:04.000000000 +0200 @@ -6,17 +6,17 @@ import socket import pytest + try: from _pytest.python import transfer_markers except ImportError: # Pytest 4.1.0 removes the transfer_marker api (#104) + def transfer_markers(*args, **kwargs): # noqa """Noop when over pytest 4.1.0""" pass -try: - from async_generator import isasyncgenfunction -except ImportError: - from inspect import isasyncgenfunction + +from inspect import isasyncgenfunction def _is_coroutine(obj): @@ -26,10 +26,12 @@ def pytest_configure(config): """Inject documentation.""" - config.addinivalue_line("markers", - "asyncio: " - "mark the test as a coroutine, it will be " - "run using an asyncio event loop") + config.addinivalue_line( + "markers", + "asyncio: " + "mark the test as a coroutine, it will be " + "run using an asyncio event loop", + ) @pytest.mark.tryfirst @@ -44,12 +46,13 @@ transfer_markers(obj, item.cls, item.module) item = pytest.Function.from_parent(collector, name=name) # To reload keywords. - if 'asyncio' in item.keywords: + if "asyncio" in item.keywords: return list(collector._genfunctions(name, obj)) class FixtureStripper: """Include additional Fixture, and then strip them""" + REQUEST = "request" EVENT_LOOP = "event_loop" @@ -59,10 +62,10 @@ def add(self, name): """Add fixture name to fixturedef - and record in to_strip list (If not previously included)""" + and record in to_strip list (If not previously included)""" if name in self.fixturedef.argnames: return - self.fixturedef.argnames += (name, ) + self.fixturedef.argnames += (name,) self.to_strip.add(name) def get_and_strip_from(self, name, data_dict): @@ -72,6 +75,7 @@ del data_dict[name] return result + @pytest.hookimpl(trylast=True) def pytest_fixture_post_finalizer(fixturedef, request): """Called after fixture teardown""" @@ -80,7 +84,6 @@ asyncio.set_event_loop_policy(None) - @pytest.hookimpl(hookwrapper=True) def pytest_fixture_setup(fixturedef, request): """Adjust the event loop policy when an event loop is produced.""" @@ -88,6 +91,13 @@ outcome = yield loop = outcome.get_result() policy = asyncio.get_event_loop_policy() + try: + old_loop = policy.get_event_loop() + if old_loop is not loop: + old_loop.close() + except RuntimeError: + # Swallow this, since it's probably bad event loop hygiene. + pass policy.set_event_loop(loop) return @@ -99,10 +109,13 @@ fixture_stripper.add(FixtureStripper.EVENT_LOOP) fixture_stripper.add(FixtureStripper.REQUEST) - def wrapper(*args, **kwargs): - loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs) - request = fixture_stripper.get_and_strip_from(FixtureStripper.REQUEST, kwargs) + loop = fixture_stripper.get_and_strip_from( + FixtureStripper.EVENT_LOOP, kwargs + ) + request = fixture_stripper.get_and_strip_from( + FixtureStripper.REQUEST, kwargs + ) gen_obj = generator(*args, **kwargs) @@ -112,6 +125,7 @@ def finalizer(): """Yield again, to finalize.""" + async def async_finalizer(): try: await gen_obj.__anext__() @@ -121,6 +135,7 @@ msg = "Async generator fixture didn't stop." msg += "Yield only once." raise ValueError(msg) + loop.run_until_complete(async_finalizer()) request.addfinalizer(finalizer) @@ -134,7 +149,9 @@ fixture_stripper.add(FixtureStripper.EVENT_LOOP) def wrapper(*args, **kwargs): - loop = fixture_stripper.get_and_strip_from(FixtureStripper.EVENT_LOOP, kwargs) + loop = fixture_stripper.get_and_strip_from( + FixtureStripper.EVENT_LOOP, kwargs + ) async def setup(): res = await coro(*args, **kwargs) @@ -152,16 +169,15 @@ Run asyncio marked test functions in an event loop instead of a normal function call. """ - if 'asyncio' in pyfuncitem.keywords: - if getattr(pyfuncitem.obj, 'is_hypothesis_test', False): + if "asyncio" in pyfuncitem.keywords: + if getattr(pyfuncitem.obj, "is_hypothesis_test", False): pyfuncitem.obj.hypothesis.inner_test = wrap_in_sync( pyfuncitem.obj.hypothesis.inner_test, - _loop=pyfuncitem.funcargs['event_loop'] + _loop=pyfuncitem.funcargs["event_loop"], ) else: pyfuncitem.obj = wrap_in_sync( - pyfuncitem.obj, - _loop=pyfuncitem.funcargs['event_loop'] + pyfuncitem.obj, _loop=pyfuncitem.funcargs["event_loop"] ) yield @@ -184,22 +200,25 @@ if task.done() and not task.cancelled(): task.exception() raise + return inner def pytest_runtest_setup(item): - if 'asyncio' in item.keywords: + if "asyncio" in item.keywords: # inject an event loop fixture for all async tests - if 'event_loop' in item.fixturenames: - item.fixturenames.remove('event_loop') - item.fixturenames.insert(0, 'event_loop') - if item.get_closest_marker("asyncio") is not None \ - and not getattr(item.obj, 'hypothesis', False) \ - and getattr(item.obj, 'is_hypothesis_test', False): - pytest.fail( - 'test function `%r` is using Hypothesis, but pytest-asyncio ' - 'only works with Hypothesis 3.64.0 or later.' % item - ) + if "event_loop" in item.fixturenames: + item.fixturenames.remove("event_loop") + item.fixturenames.insert(0, "event_loop") + if ( + item.get_closest_marker("asyncio") is not None + and not getattr(item.obj, "hypothesis", False) + and getattr(item.obj, "is_hypothesis_test", False) + ): + pytest.fail( + "test function `%r` is using Hypothesis, but pytest-asyncio " + "only works with Hypothesis 3.64.0 or later." % item + ) @pytest.fixture @@ -213,7 +232,7 @@ def _unused_tcp_port(): """Find an unused localhost TCP port from 1024-65535 and return it.""" with contextlib.closing(socket.socket()) as sock: - sock.bind(('127.0.0.1', 0)) + sock.bind(("127.0.0.1", 0)) return sock.getsockname()[1] @@ -222,7 +241,7 @@ return _unused_tcp_port() -@pytest.fixture +@pytest.fixture(scope="session") def unused_tcp_port_factory(): """A factory function, producing different unused TCP ports.""" produced = set() @@ -237,4 +256,5 @@ produced.add(port) return port + return factory diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/setup.cfg new/pytest-asyncio-0.15.1/setup.cfg --- old/pytest-asyncio-0.14.0/setup.cfg 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/setup.cfg 2021-04-22 01:04:04.000000000 +0200 @@ -12,3 +12,6 @@ [metadata] # ensure LICENSE is included in wheel metadata license_file = LICENSE + +[flake8] +ignore = E203, E501, W503 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/setup.py new/pytest-asyncio-0.15.1/setup.py --- old/pytest-asyncio-0.14.0/setup.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/setup.py 2021-04-22 01:04:04.000000000 +0200 @@ -33,20 +33,18 @@ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Topic :: Software Development :: Testing", "Framework :: Pytest", ], - python_requires=">= 3.5", + python_requires=">= 3.6", install_requires=["pytest >= 5.4.0"], extras_require={ - ':python_version == "3.5"': "async_generator >= 1.3", "testing": [ "coverage", - "async_generator >= 1.3", "hypothesis >= 5.7.1", ], }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,25 @@ +import asyncio +import unittest.mock + +import pytest + +START = object() +END = object() +RETVAL = object() + + +@pytest.fixture +def mock(): + return unittest.mock.Mock(return_value=RETVAL) + + +@pytest.fixture +async def async_fixture(mock): + return await asyncio.sleep(0.1, result=mock(START)) + + +@pytest.mark.asyncio +async def test_async_fixture(async_fixture, mock): + assert mock.call_count == 1 + assert mock.call_args_list[-1] == unittest.mock.call(START) + assert async_fixture is RETVAL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures_35.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures_35.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures_35.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures_35.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ -import asyncio -import unittest.mock - -import pytest - -START = object() -END = object() -RETVAL = object() - - -@pytest.fixture -def mock(): - return unittest.mock.Mock(return_value=RETVAL) - - -@pytest.fixture -async def async_fixture(mock): - return await asyncio.sleep(0.1, result=mock(START)) - - -@pytest.mark.asyncio -async def test_async_fixture(async_fixture, mock): - assert mock.call_count == 1 - assert mock.call_args_list[-1] == unittest.mock.call(START) - assert async_fixture is RETVAL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures_scope.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures_scope.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures_scope.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures_scope.py 2021-04-22 01:04:04.000000000 +0200 @@ -3,16 +3,17 @@ module-scoped too. """ import asyncio + import pytest -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") def event_loop(): """A module-scoped event loop.""" return asyncio.new_event_loop() -@pytest.fixture(scope='module') +@pytest.fixture(scope="module") async def async_fixture(): await asyncio.sleep(0.1) return 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures_with_finalizer.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures_with_finalizer.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_fixtures_with_finalizer.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_fixtures_with_finalizer.py 2021-04-22 01:04:04.000000000 +0200 @@ -1,5 +1,6 @@ import asyncio import functools + import pytest @@ -8,11 +9,13 @@ await asyncio.sleep(0.01) assert port_with_event_loop_finalizer + @pytest.mark.asyncio async def test_module_with_get_event_loop_finalizer(port_with_get_event_loop_finalizer): await asyncio.sleep(0.01) assert port_with_get_event_loop_finalizer + @pytest.fixture(scope="module") def event_loop(): """Change event_loop fixture to module level.""" @@ -29,6 +32,7 @@ # await task using loop provided by event_loop fixture # RuntimeError is raised if task is created on a different loop await finalizer + event_loop.run_until_complete(port_afinalizer()) worker = asyncio.ensure_future(asyncio.sleep(0.2)) @@ -43,6 +47,7 @@ # await task using loop provided by asyncio.get_event_loop() # RuntimeError is raised if task is created on a different loop await finalizer + asyncio.get_event_loop().run_until_complete(port_afinalizer()) worker = asyncio.ensure_future(asyncio.sleep(0.2)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_gen_fixtures.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_gen_fixtures.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_gen_fixtures.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_gen_fixtures.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,38 @@ +import unittest.mock + +import pytest + +START = object() +END = object() +RETVAL = object() + + +@pytest.fixture(scope="module") +def mock(): + return unittest.mock.Mock(return_value=RETVAL) + + +@pytest.fixture +async def async_gen_fixture(mock): + try: + yield mock(START) + except Exception as e: + mock(e) + else: + mock(END) + + +@pytest.mark.asyncio +async def test_async_gen_fixture(async_gen_fixture, mock): + assert mock.called + assert mock.call_args_list[-1] == unittest.mock.call(START) + assert async_gen_fixture is RETVAL + + +@pytest.mark.asyncio +async def test_async_gen_fixture_finalized(mock): + try: + assert mock.called + assert mock.call_args_list[-1] == unittest.mock.call(END) + finally: + mock.reset_mock() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_gen_fixtures_35.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_gen_fixtures_35.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_gen_fixtures_35.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_gen_fixtures_35.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,40 +0,0 @@ -import unittest.mock - -import pytest -from async_generator import yield_, async_generator - -START = object() -END = object() -RETVAL = object() - - -@pytest.fixture(scope='module') -def mock(): - return unittest.mock.Mock(return_value=RETVAL) - - -@pytest.fixture -@async_generator -async def async_gen_fixture(mock): - try: - await yield_(mock(START)) - except Exception as e: - mock(e) - else: - mock(END) - - -@pytest.mark.asyncio -async def test_async_gen_fixture(async_gen_fixture, mock): - assert mock.called - assert mock.call_args_list[-1] == unittest.mock.call(START) - assert async_gen_fixture is RETVAL - - -@pytest.mark.asyncio -async def test_async_gen_fixture_finalized(mock): - try: - assert mock.called - assert mock.call_args_list[-1] == unittest.mock.call(END) - finally: - mock.reset_mock() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_gen_fixtures_36.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_gen_fixtures_36.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_async_gen_fixtures_36.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_async_gen_fixtures_36.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,39 +0,0 @@ -import asyncio -import unittest.mock - -import pytest - -START = object() -END = object() -RETVAL = object() - - -@pytest.fixture(scope='module') -def mock(): - return unittest.mock.Mock(return_value=RETVAL) - - -@pytest.fixture -async def async_gen_fixture(mock): - try: - yield mock(START) - except Exception as e: - mock(e) - else: - mock(END) - - -@pytest.mark.asyncio -async def test_async_gen_fixture(async_gen_fixture, mock): - assert mock.called - assert mock.call_args_list[-1] == unittest.mock.call(START) - assert async_gen_fixture is RETVAL - - -@pytest.mark.asyncio -async def test_async_gen_fixture_finalized(mock): - try: - assert mock.called - assert mock.call_args_list[-1] == unittest.mock.call(END) - finally: - mock.reset_mock() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_coroutine_fixtures.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_coroutine_fixtures.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_coroutine_fixtures.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_coroutine_fixtures.py 2021-04-22 01:04:04.000000000 +0200 @@ -7,7 +7,9 @@ END = object() RETVAL = object() -pytestmark = pytest.mark.skip(reason='@asyncio.coroutine fixtures are not supported yet') +pytestmark = pytest.mark.skip( + reason="@asyncio.coroutine fixtures are not supported yet" +) @pytest.fixture diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_nested.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_nested.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_nested.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_nested.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,26 @@ +import asyncio + +import pytest + + +@pytest.fixture() +async def async_inner_fixture(): + await asyncio.sleep(0.01) + print("inner start") + yield True + print("inner stop") + + +@pytest.fixture() +async def async_fixture_outer(async_inner_fixture, event_loop): + await asyncio.sleep(0.01) + print("outer start") + assert async_inner_fixture is True + yield True + print("outer stop") + + +@pytest.mark.asyncio +async def test_async_fixture(async_fixture_outer): + assert async_fixture_outer is True + print("test_async_fixture") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/async_fixtures/test_nested_36.py new/pytest-asyncio-0.15.1/tests/async_fixtures/test_nested_36.py --- old/pytest-asyncio-0.14.0/tests/async_fixtures/test_nested_36.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/async_fixtures/test_nested_36.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,25 +0,0 @@ -import asyncio -import pytest - - -@pytest.fixture() -async def async_inner_fixture(): - await asyncio.sleep(0.01) - print('inner start') - yield True - print('inner stop') - - -@pytest.fixture() -async def async_fixture_outer(async_inner_fixture, event_loop): - await asyncio.sleep(0.01) - print('outer start') - assert async_inner_fixture is True - yield True - print('outer stop') - - -@pytest.mark.asyncio -async def test_async_fixture(async_fixture_outer): - assert async_fixture_outer is True - print('test_async_fixture') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/conftest.py new/pytest-asyncio-0.15.1/tests/conftest.py --- old/pytest-asyncio-0.14.0/tests/conftest.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/conftest.py 2021-04-22 01:04:04.000000000 +0200 @@ -1,13 +1,7 @@ import asyncio -import sys import pytest -collect_ignore = [] -if sys.version_info[:2] < (3, 6): - collect_ignore.append("async_fixtures/test_async_gen_fixtures_36.py") - collect_ignore.append("async_fixtures/test_nested_36.py") - @pytest.fixture def dependent_fixture(event_loop): @@ -26,3 +20,11 @@ event_loop.run_until_complete(just_a_sleep()) assert counter == 2 + + +@pytest.fixture(scope="session", name="factory_involving_factories") +def factory_involving_factories_fixture(unused_tcp_port_factory): + def factory(): + return unused_tcp_port_factory() + + return factory diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/markers/test_class_marker.py new/pytest-asyncio-0.15.1/tests/markers/test_class_marker.py --- old/pytest-asyncio-0.14.0/tests/markers/test_class_marker.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/markers/test_class_marker.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,25 @@ +"""Test if pytestmark works when defined on a class.""" +import asyncio + +import pytest + + +class TestPyTestMark: + pytestmark = pytest.mark.asyncio + + async def test_is_asyncio(self, event_loop, sample_fixture): + assert asyncio.get_event_loop() + counter = 1 + + async def inc(): + nonlocal counter + counter += 1 + await asyncio.sleep(0) + + await asyncio.ensure_future(inc()) + assert counter == 2 + + +@pytest.fixture +def sample_fixture(): + return None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/markers/test_class_marker_35.py new/pytest-asyncio-0.15.1/tests/markers/test_class_marker_35.py --- old/pytest-asyncio-0.14.0/tests/markers/test_class_marker_35.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/markers/test_class_marker_35.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,23 +0,0 @@ -"""Test if pytestmark works when defined on a class.""" -import asyncio -import pytest - - -class TestPyTestMark: - pytestmark = pytest.mark.asyncio - - async def test_is_asyncio(self, event_loop, sample_fixture): - assert asyncio.get_event_loop() - counter = 1 - - async def inc(): - nonlocal counter - counter += 1 - await asyncio.sleep(0) - await asyncio.ensure_future(inc()) - assert counter == 2 - - -@pytest.fixture -def sample_fixture(): - return None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/markers/test_module_marker.py new/pytest-asyncio-0.15.1/tests/markers/test_module_marker.py --- old/pytest-asyncio-0.14.0/tests/markers/test_module_marker.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/markers/test_module_marker.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,39 @@ +"""Test if pytestmark works when defined in a module.""" +import asyncio + +import pytest + +pytestmark = pytest.mark.asyncio + + +class TestPyTestMark: + async def test_is_asyncio(self, event_loop, sample_fixture): + assert asyncio.get_event_loop() + + counter = 1 + + async def inc(): + nonlocal counter + counter += 1 + await asyncio.sleep(0) + + await asyncio.ensure_future(inc()) + assert counter == 2 + + +async def test_is_asyncio(event_loop, sample_fixture): + assert asyncio.get_event_loop() + counter = 1 + + async def inc(): + nonlocal counter + counter += 1 + await asyncio.sleep(0) + + await asyncio.ensure_future(inc()) + assert counter == 2 + + +@pytest.fixture +def sample_fixture(): + return None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/markers/test_module_marker_35.py new/pytest-asyncio-0.15.1/tests/markers/test_module_marker_35.py --- old/pytest-asyncio-0.14.0/tests/markers/test_module_marker_35.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/markers/test_module_marker_35.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,37 +0,0 @@ -"""Test if pytestmark works when defined in a module.""" -import asyncio - -import pytest - -pytestmark = pytest.mark.asyncio - - -class TestPyTestMark: - async def test_is_asyncio(self, event_loop, sample_fixture): - assert asyncio.get_event_loop() - - counter = 1 - - async def inc(): - nonlocal counter - counter += 1 - await asyncio.sleep(0) - - await asyncio.ensure_future(inc()) - assert counter == 2 - - -async def test_is_asyncio(event_loop, sample_fixture): - assert asyncio.get_event_loop() - counter = 1 - async def inc(): - nonlocal counter - counter += 1 - await asyncio.sleep(0) - await asyncio.ensure_future(inc()) - assert counter == 2 - - -@pytest.fixture -def sample_fixture(): - return None diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/multiloop/conftest.py new/pytest-asyncio-0.15.1/tests/multiloop/conftest.py --- old/pytest-asyncio-0.14.0/tests/multiloop/conftest.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/multiloop/conftest.py 2021-04-22 01:04:04.000000000 +0200 @@ -5,6 +5,7 @@ class CustomSelectorLoop(asyncio.SelectorEventLoop): """A subclass with no overrides, just to test for presence.""" + pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/sessionloop/conftest.py new/pytest-asyncio-0.15.1/tests/sessionloop/conftest.py --- old/pytest-asyncio-0.14.0/tests/sessionloop/conftest.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/sessionloop/conftest.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,19 @@ +import asyncio + +import pytest + + +class CustomSelectorLoopSession(asyncio.SelectorEventLoop): + """A subclass with no overrides, just to test for presence.""" + + pass + + +loop = CustomSelectorLoopSession() + + +@pytest.fixture(scope="package") +def event_loop(): + """Create an instance of the default event loop for each test case.""" + yield loop + loop.close() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/sessionloop/test_session_loops.py new/pytest-asyncio-0.15.1/tests/sessionloop/test_session_loops.py --- old/pytest-asyncio-0.14.0/tests/sessionloop/test_session_loops.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/sessionloop/test_session_loops.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,16 @@ +"""Unit tests for overriding the event loop with a session scoped one.""" +import asyncio + +import pytest + + +@pytest.mark.asyncio +async def test_for_custom_loop(): + """This test should be executed using the custom loop.""" + await asyncio.sleep(0.01) + assert type(asyncio.get_event_loop()).__name__ == "CustomSelectorLoopSession" + + +@pytest.mark.asyncio +async def test_dependent_fixture(dependent_fixture): + await asyncio.sleep(0.1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/test_dependent_fixtures.py new/pytest-asyncio-0.15.1/tests/test_dependent_fixtures.py --- old/pytest-asyncio-0.14.0/tests/test_dependent_fixtures.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/test_dependent_fixtures.py 2021-04-22 01:04:04.000000000 +0200 @@ -6,3 +6,8 @@ async def test_dependent_fixture(dependent_fixture): """Test a dependent fixture.""" await asyncio.sleep(0.1) + + +@pytest.mark.asyncio +async def test_factory_involving_factories(factory_involving_factories): + factory_involving_factories() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/test_event_loop_scope.py new/pytest-asyncio-0.15.1/tests/test_event_loop_scope.py --- old/pytest-asyncio-0.14.0/tests/test_event_loop_scope.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-asyncio-0.15.1/tests/test_event_loop_scope.py 2021-04-22 01:04:04.000000000 +0200 @@ -0,0 +1,22 @@ +"""Test the event loop fixture is properly disposed of. + +These tests need to be run together. +""" +import asyncio + +import pytest + + +def test_1(): + loop = asyncio.get_event_loop() + assert not loop.is_closed() + + +@pytest.mark.asyncio +async def test_2(): + pass + + +def test_3(): + loop = asyncio.get_event_loop() + assert not loop.is_closed() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/test_event_loop_scope_35.py new/pytest-asyncio-0.15.1/tests/test_event_loop_scope_35.py --- old/pytest-asyncio-0.14.0/tests/test_event_loop_scope_35.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/test_event_loop_scope_35.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,21 +0,0 @@ -"""Test the event loop fixture is properly disposed of. - -These tests need to be run together. -""" -import asyncio -import pytest - - -def test_1(): - loop = asyncio.get_event_loop() - assert not loop.is_closed() - - -@pytest.mark.asyncio -async def test_2(): - pass - - -def test_3(): - loop = asyncio.get_event_loop() - assert not loop.is_closed() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/test_simple.py new/pytest-asyncio-0.15.1/tests/test_simple.py --- old/pytest-asyncio-0.14.0/tests/test_simple.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/test_simple.py 2021-04-22 01:04:04.000000000 +0200 @@ -1,20 +1,20 @@ """Quick'n'dirty unit tests for provided fixtures and markers.""" import asyncio -import pytest +import pytest import pytest_asyncio.plugin async def async_coro(): await asyncio.sleep(0) - return 'ok' + return "ok" def test_event_loop_fixture(event_loop): """Test the injection of the event_loop fixture.""" assert event_loop ret = event_loop.run_until_complete(async_coro()) - assert ret == 'ok' + assert ret == "ok" @pytest.mark.asyncio @@ -23,7 +23,7 @@ await asyncio.sleep(0) -@pytest.mark.xfail(reason='need a failure', strict=True) +@pytest.mark.xfail(reason="need a failure", strict=True) @pytest.mark.asyncio def test_asyncio_marker_fail(): assert False @@ -42,12 +42,10 @@ async def closer(_, writer): writer.close() - server1 = await asyncio.start_server(closer, host='localhost', - port=unused_tcp_port) + server1 = await asyncio.start_server(closer, host="localhost", port=unused_tcp_port) with pytest.raises(IOError): - await asyncio.start_server(closer, host='localhost', - port=unused_tcp_port) + await asyncio.start_server(closer, host="localhost", port=unused_tcp_port) server1.close() await server1.wait_closed() @@ -60,20 +58,19 @@ async def closer(_, writer): writer.close() - port1, port2, port3 = (unused_tcp_port_factory(), unused_tcp_port_factory(), - unused_tcp_port_factory()) - - server1 = await asyncio.start_server(closer, host='localhost', - port=port1) - server2 = await asyncio.start_server(closer, host='localhost', - port=port2) - server3 = await asyncio.start_server(closer, host='localhost', - port=port3) + port1, port2, port3 = ( + unused_tcp_port_factory(), + unused_tcp_port_factory(), + unused_tcp_port_factory(), + ) + + server1 = await asyncio.start_server(closer, host="localhost", port=port1) + server2 = await asyncio.start_server(closer, host="localhost", port=port2) + server3 = await asyncio.start_server(closer, host="localhost", port=port3) for port in port1, port2, port3: with pytest.raises(IOError): - await asyncio.start_server(closer, host='localhost', - port=port) + await asyncio.start_server(closer, host="localhost", port=port) server1.close() await server1.wait_closed() @@ -96,8 +93,7 @@ else: return 10000 + counter - monkeypatch.setattr(pytest_asyncio.plugin, '_unused_tcp_port', - mock_unused_tcp_port) + monkeypatch.setattr(pytest_asyncio.plugin, "_unused_tcp_port", mock_unused_tcp_port) assert unused_tcp_port_factory() == 10000 assert unused_tcp_port_factory() > 10000 @@ -110,7 +106,7 @@ async def test_asyncio_marker_method(self, event_loop): """Test the asyncio pytest marker in a Test class.""" ret = await async_coro() - assert ret == 'ok' + assert ret == "ok" class TestUnexistingLoop: @@ -125,7 +121,7 @@ async def test_asyncio_marker_without_loop(self, remove_loop): """Test the asyncio pytest marker in a Test class.""" ret = await async_coro() - assert ret == 'ok' + assert ret == "ok" class TestEventLoopStartedBeforeFixtures: @@ -150,7 +146,11 @@ assert await loop.run_in_executor(None, self.foo) == 1 - @pytest.mark.asyncio async def test_no_warning_on_skip(): pytest.skip("Test a skip error inside asyncio") + + +def test_async_close_loop(event_loop): + event_loop.close() + return "ok" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/test_simple_35.py new/pytest-asyncio-0.15.1/tests/test_simple_35.py --- old/pytest-asyncio-0.14.0/tests/test_simple_35.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/test_simple_35.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,83 +0,0 @@ -"""Quick'n'dirty unit tests using async and await syntax.""" -import asyncio - -import pytest - - -@pytest.mark.asyncio -async def async_coro(loop): - await asyncio.sleep(0) - return 'ok' - - -@pytest.mark.asyncio -async def test_asyncio_marker(): - """Test the asyncio pytest marker.""" - - -@pytest.mark.asyncio -async def test_asyncio_marker_with_default_param(a_param=None): - """Test the asyncio pytest marker.""" - - -@pytest.mark.asyncio -async def test_unused_port_fixture(unused_tcp_port, event_loop): - """Test the unused TCP port fixture.""" - async def closer(_, writer): - writer.close() - - server1 = await asyncio.start_server(closer, host='localhost', - port=unused_tcp_port) - - server1.close() - await server1.wait_closed() - - -def test_unused_port_factory_fixture(unused_tcp_port_factory, event_loop): - """Test the unused TCP port factory fixture.""" - - async def closer(_, writer): - writer.close() - - port1, port2, port3 = (unused_tcp_port_factory(), unused_tcp_port_factory(), - unused_tcp_port_factory()) - - async def run_test(): - server1 = await asyncio.start_server(closer, host='localhost', - port=port1) - server2 = await asyncio.start_server(closer, host='localhost', - port=port2) - server3 = await asyncio.start_server(closer, host='localhost', - port=port3) - - for port in port1, port2, port3: - with pytest.raises(IOError): - await asyncio.start_server(closer, host='localhost', - port=port) - - server1.close() - await server1.wait_closed() - server2.close() - await server2.wait_closed() - server3.close() - await server3.wait_closed() - - event_loop.run_until_complete(run_test()) - - event_loop.stop() - event_loop.close() - - -class Test: - """Test that asyncio marked functions work in test methods.""" - - @pytest.mark.asyncio - async def test_asyncio_marker_method(self, event_loop): - """Test the asyncio pytest marker in a Test class.""" - ret = await async_coro(event_loop) - assert ret == 'ok' - - -def test_async_close_loop(event_loop): - event_loop.close() - return 'ok' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tests/test_subprocess.py new/pytest-asyncio-0.15.1/tests/test_subprocess.py --- old/pytest-asyncio-0.14.0/tests/test_subprocess.py 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tests/test_subprocess.py 2021-04-22 01:04:04.000000000 +0200 @@ -1,12 +1,11 @@ """Tests for using subprocesses in tests.""" -import sys import asyncio import asyncio.subprocess +import sys import pytest - -if sys.platform == 'win32': +if sys.platform == "win32": # The default asyncio event loop implementation on Windows does not # support subprocesses. Subprocesses are available for Windows if a # ProactorEventLoop is used. @@ -21,7 +20,8 @@ async def test_subprocess(event_loop): """Starting a subprocess should be possible.""" proc = await asyncio.subprocess.create_subprocess_exec( - sys.executable, '--version', stdout=asyncio.subprocess.PIPE) + sys.executable, "--version", stdout=asyncio.subprocess.PIPE + ) await proc.communicate() @@ -29,5 +29,6 @@ async def test_subprocess_forbid(event_loop): """Starting a subprocess should be possible.""" proc = await asyncio.subprocess.create_subprocess_exec( - sys.executable, '--version', stdout=asyncio.subprocess.PIPE) + sys.executable, "--version", stdout=asyncio.subprocess.PIPE + ) await proc.communicate() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-asyncio-0.14.0/tox.ini new/pytest-asyncio-0.15.1/tox.ini --- old/pytest-asyncio-0.14.0/tox.ini 2020-06-24 00:12:15.000000000 +0200 +++ new/pytest-asyncio-0.15.1/tox.ini 2021-04-22 01:04:04.000000000 +0200 @@ -1,15 +1,33 @@ [tox] minversion = 3.14.0 -envlist = py35, py36, py37, py38 +envlist = py36, py37, py38, py39, lint skip_missing_interpreters = true [testenv] extras = testing commands = coverage run -m pytest {posargs} +[testenv:lint] +skip_install = true +basepython = python3.9 +extras = tests +deps = + flake8 + black +commands = + make lint + [testenv:coverage-report] deps = coverage skip_install = true commands = coverage combine coverage report + +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + 3.9: py39, lint + pypy3: pypy3