Skip to content

Commit

Permalink
Merge pull request #60 from finsberg/finsberg/fix_pytest_deprecation_…
Browse files Browse the repository at this point in the history
…warning_pytestFunction

Fix pytest deprecation warning for pytest version greater than 5.4
  • Loading branch information
vidartf committed May 12, 2020
2 parents 52ba511 + 7b37148 commit b37409d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion pytest_tornado/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import types
import inspect
import datetime
import pkg_resources
import pytest
import tornado
import tornado.gen
Expand All @@ -15,6 +16,8 @@
else:
iscoroutinefunction = lambda f: False

_PYTEST_VERSION = pkg_resources.parse_version(pytest.__version__)


def _get_async_test_timeout():
try:
Expand Down Expand Up @@ -67,7 +70,10 @@ def _timeout(item):
@pytest.mark.tryfirst
def pytest_pycollect_makeitem(collector, name, obj):
if collector.funcnamefilter(name) and inspect.isgeneratorfunction(obj):
item = pytest.Function(name, parent=collector)
if _PYTEST_VERSION >= pkg_resources.parse_version("5.4.0"):
item = pytest.Function.from_parent(collector, name=name)
else:
item = pytest.Function(name, parent=collector)
if 'gen_test' in item.keywords:
return list(collector._genfunctions(name, obj))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
keywords=('pytest py.test tornado async asynchronous '
'testing unit tests plugin'),
packages=find_packages(exclude=["tests.*", "tests"]),
install_requires=['pytest>=3.6', 'tornado>=4.1'],
install_requires=['pytest>=3.6', 'tornado>=4.1', 'setuptools'],
entry_points={
'pytest11': ['tornado = pytest_tornado.plugin'],
},
Expand Down

0 comments on commit b37409d

Please sign in to comment.