Hello community,
here is the log from the commit of package python-pytest-asyncio for
openSUSE:Factory checked in at 2019-02-14 14:34:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-asyncio (Old)
and /work/SRC/openSUSE:Factory/.python-pytest-asyncio.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-asyncio"
Thu Feb 14 14:34:22 2019 rev:3 rq:674560 version:0.10.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-pytest-asyncio/python-pytest-asyncio.changes
2018-09-11 17:15:03.127617477 +0200
+++
/work/SRC/openSUSE:Factory/.python-pytest-asyncio.new.28833/python-pytest-asyncio.changes
2019-02-14 14:34:24.647623918 +0100
@@ -1,0 +2,6 @@
+Wed Feb 13 13:14:40 UTC 2019 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.10.0:
+ * support for pytest 4+
+
+-------------------------------------------------------------------
Old:
----
pytest-asyncio-0.9.0.tar.gz
New:
----
pytest-asyncio-0.10.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pytest-asyncio.spec ++++++
--- /var/tmp/diff_new_pack.3i88MH/_old 2019-02-14 14:34:25.155623688 +0100
+++ /var/tmp/diff_new_pack.3i88MH/_new 2019-02-14 14:34:25.159623686 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-pytest-asyncio
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,29 +12,27 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define skip_python2 1
%{?!python_module:%define python_module() python3-%{**}}
Name: python-pytest-asyncio
-Version: 0.9.0
+Version: 0.10.0
Release: 0
Summary: Pytest support for asyncio
License: Apache-2.0
Group: Development/Languages/Python
URL: https://github.com/pytest-dev/pytest-asyncio
-#Source:
https://files.pythonhosted.org/packages/source/p/pytest-asyncio/pytest-asyncio-%{version}.tar.gz
Source:
https://github.com/pytest-dev/pytest-asyncio/archive/v%{version}.tar.gz#./pytest-asyncio-%{version}.tar.gz
-BuildRequires: %{python_module async_generator}
-BuildRequires: %{python_module pytest}
+BuildRequires: %{python_module async_generator >= 1.3}
+BuildRequires: %{python_module hypothesis >= 3.64}
+BuildRequires: %{python_module pytest >= 3.0.6}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-pytest >= 3.0.6
-Suggests: python-async_generator >= 1.3
-Suggests: python-coverage
BuildArch: noarch
%python_subpackages
++++++ pytest-asyncio-0.9.0.tar.gz -> pytest-asyncio-0.10.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-asyncio-0.9.0/.gitignore
new/pytest-asyncio-0.10.0/.gitignore
--- old/pytest-asyncio-0.9.0/.gitignore 2018-07-28 16:33:29.000000000 +0200
+++ new/pytest-asyncio-0.10.0/.gitignore 2019-01-08 01:24:49.000000000
+0100
@@ -22,6 +22,7 @@
*.egg-info/
.installed.cfg
*.egg
+.hypothesis/
# PyInstaller
# Usually these files are written by a python script from a template
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-asyncio-0.9.0/README.rst
new/pytest-asyncio-0.10.0/README.rst
--- old/pytest-asyncio-0.9.0/README.rst 2018-07-28 16:33:29.000000000 +0200
+++ new/pytest-asyncio-0.10.0/README.rst 2019-01-08 01:24:49.000000000
+0100
@@ -176,6 +176,14 @@
Changelog
---------
+0.10.0. (UNRELEASED)
+~~~~~~~~~~~~~~~~~~~~
+- ``pytest-asyncio`` integrates with `Hypothesis
<https://hypothesis.readthedocs.io>`_
+ to support ``@given`` on async test functions using ``asyncio``.
+ `#102` <https://github.com/pytest-dev/pytest-asyncio/pull/102>
+- Pytest 4.1 support.
+ `#105` <https://github.com/pytest-dev/pytest-asyncio/pull/105>
+
0.9.0 (2018-07-28)
~~~~~~~~~~~~~~~~~~
- Python 3.7 support.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-asyncio-0.9.0/pytest_asyncio/__init__.py
new/pytest-asyncio-0.10.0/pytest_asyncio/__init__.py
--- old/pytest-asyncio-0.9.0/pytest_asyncio/__init__.py 2018-07-28
16:33:29.000000000 +0200
+++ new/pytest-asyncio-0.10.0/pytest_asyncio/__init__.py 2019-01-08
01:24:49.000000000 +0100
@@ -1,2 +1,2 @@
"""The main point for importing pytest-asyncio items."""
-__version__ = "0.9.0"
+__version__ = "0.10.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-asyncio-0.9.0/pytest_asyncio/plugin.py
new/pytest-asyncio-0.10.0/pytest_asyncio/plugin.py
--- old/pytest-asyncio-0.9.0/pytest_asyncio/plugin.py 2018-07-28
16:33:29.000000000 +0200
+++ new/pytest-asyncio-0.10.0/pytest_asyncio/plugin.py 2019-01-08
01:24:49.000000000 +0100
@@ -1,11 +1,17 @@
"""pytest-asyncio implementation."""
import asyncio
import contextlib
+import functools
import inspect
import socket
import pytest
-from _pytest.python import transfer_markers
+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
@@ -139,7 +145,8 @@
function call.
"""
for marker_name, fixture_name in _markers_2_fixtures.items():
- if marker_name in pyfuncitem.keywords:
+ if marker_name in pyfuncitem.keywords \
+ and not getattr(pyfuncitem.obj, 'is_hypothesis_test', False):
event_loop = pyfuncitem.funcargs[fixture_name]
funcargs = pyfuncitem.funcargs
@@ -152,11 +159,39 @@
return True
+def wrap_in_sync(func):
+ """Return a sync wrapper around an async function."""
+
+ @functools.wraps(func)
+ def inner(**kwargs):
+ loop = asyncio.get_event_loop_policy().new_event_loop()
+ try:
+ coro = func(**kwargs)
+ if coro is not None:
+ future = asyncio.ensure_future(coro, loop=loop)
+ loop.run_until_complete(future)
+ finally:
+ loop.close()
+
+ return inner
+
+
def pytest_runtest_setup(item):
for marker, fixture in _markers_2_fixtures.items():
if marker in item.keywords and fixture not in item.fixturenames:
# inject an event loop fixture for all async tests
item.fixturenames.append(fixture)
+ if item.get_closest_marker("asyncio") is not None:
+ if hasattr(item.obj, 'hypothesis'):
+ # If it's a Hypothesis test, we insert the wrap_in_sync decorator
+ item.obj.hypothesis.inner_test = wrap_in_sync(
+ item.obj.hypothesis.inner_test
+ )
+ elif 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
+ )
# maps marker to the name of the event loop fixture that will be available
@@ -174,8 +209,7 @@
loop.close()
[email protected]
-def unused_tcp_port():
+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))
@@ -183,16 +217,21 @@
@pytest.fixture
+def unused_tcp_port():
+ return _unused_tcp_port()
+
+
[email protected]
def unused_tcp_port_factory():
"""A factory function, producing different unused TCP ports."""
produced = set()
def factory():
"""Return an unused port."""
- port = unused_tcp_port()
+ port = _unused_tcp_port()
while port in produced:
- port = unused_tcp_port()
+ port = _unused_tcp_port()
produced.add(port)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-asyncio-0.9.0/setup.cfg
new/pytest-asyncio-0.10.0/setup.cfg
--- old/pytest-asyncio-0.9.0/setup.cfg 2018-07-28 16:33:29.000000000 +0200
+++ new/pytest-asyncio-0.10.0/setup.cfg 2019-01-08 01:24:49.000000000 +0100
@@ -7,6 +7,7 @@
[tool:pytest]
addopts = -rsx --tb=short
testpaths = tests
+filterwarnings = error
[metadata]
# ensure LICENSE is included in wheel metadata
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-asyncio-0.9.0/setup.py
new/pytest-asyncio-0.10.0/setup.py
--- old/pytest-asyncio-0.9.0/setup.py 2018-07-28 16:33:29.000000000 +0200
+++ new/pytest-asyncio-0.10.0/setup.py 2019-01-08 01:24:49.000000000 +0100
@@ -43,7 +43,11 @@
install_requires=["pytest >= 3.0.6"],
extras_require={
':python_version == "3.5"': "async_generator >= 1.3",
- "testing": ["coverage", "async_generator >= 1.3"],
+ "testing": [
+ "coverage",
+ "async_generator >= 1.3",
+ "hypothesis >= 3.64",
+ ],
},
entry_points={"pytest11": ["asyncio = pytest_asyncio.plugin"]},
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pytest-asyncio-0.9.0/tests/test_hypothesis_integration.py
new/pytest-asyncio-0.10.0/tests/test_hypothesis_integration.py
--- old/pytest-asyncio-0.9.0/tests/test_hypothesis_integration.py
1970-01-01 01:00:00.000000000 +0100
+++ new/pytest-asyncio-0.10.0/tests/test_hypothesis_integration.py
2019-01-08 01:24:49.000000000 +0100
@@ -0,0 +1,27 @@
+"""Tests for the Hypothesis integration, which wraps async functions in a
+sync shim for Hypothesis.
+"""
+
+import pytest
+
+from hypothesis import given, strategies as st
+
+
+@given(st.integers())
[email protected]
+async def test_mark_inner(n):
+ assert isinstance(n, int)
+
+
[email protected]
+@given(st.integers())
+async def test_mark_outer(n):
+ assert isinstance(n, int)
+
+
[email protected]("y", [1, 2])
+@given(x=st.none())
[email protected]
+async def test_mark_and_parametrize(x, y):
+ assert x is None
+ assert y in (1, 2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pytest-asyncio-0.9.0/tests/test_simple.py
new/pytest-asyncio-0.10.0/tests/test_simple.py
--- old/pytest-asyncio-0.9.0/tests/test_simple.py 2018-07-28
16:33:29.000000000 +0200
+++ new/pytest-asyncio-0.10.0/tests/test_simple.py 2019-01-08
01:24:49.000000000 +0100
@@ -104,7 +104,7 @@
else:
return 10000 + counter
- monkeypatch.setattr(pytest_asyncio.plugin, 'unused_tcp_port',
+ monkeypatch.setattr(pytest_asyncio.plugin, '_unused_tcp_port',
mock_unused_tcp_port)
assert unused_tcp_port_factory() == 10000