mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-08 02:24:08 +00:00
Merge pull request #3841 from minrk/asyncio-mode
adopt pytest-asyncio asyncio_mode='auto'
This commit is contained in:
@@ -11,7 +11,8 @@ jupyterlab >=3
|
|||||||
mock
|
mock
|
||||||
pre-commit
|
pre-commit
|
||||||
pytest>=3.3
|
pytest>=3.3
|
||||||
pytest-asyncio
|
pytest-asyncio; python_version < "3.7"
|
||||||
|
pytest-asyncio>=0.17; python_version >= "3.7"
|
||||||
pytest-cov
|
pytest-cov
|
||||||
requests-mock
|
requests-mock
|
||||||
tbump
|
tbump
|
||||||
|
@@ -59,12 +59,14 @@ from .utils import add_user
|
|||||||
_db = None
|
_db = None
|
||||||
|
|
||||||
|
|
||||||
def pytest_collection_modifyitems(items):
|
def _pytest_collection_modifyitems(items):
|
||||||
"""This function is automatically run by pytest passing all collected test
|
"""This function is automatically run by pytest passing all collected test
|
||||||
functions.
|
functions.
|
||||||
|
|
||||||
We use it to add asyncio marker to all async tests and assert we don't use
|
We use it to add asyncio marker to all async tests and assert we don't use
|
||||||
test functions that are async generators which wouldn't make sense.
|
test functions that are async generators which wouldn't make sense.
|
||||||
|
|
||||||
|
It is no longer required with pytest-asyncio >= 0.17
|
||||||
"""
|
"""
|
||||||
for item in items:
|
for item in items:
|
||||||
if inspect.iscoroutinefunction(item.obj):
|
if inspect.iscoroutinefunction(item.obj):
|
||||||
@@ -72,6 +74,13 @@ def pytest_collection_modifyitems(items):
|
|||||||
assert not inspect.isasyncgenfunction(item.obj)
|
assert not inspect.isasyncgenfunction(item.obj)
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info < (3, 7):
|
||||||
|
# apply pytest-asyncio's 'auto' mode on Python 3.6.
|
||||||
|
# 'auto' mode is new in pytest-asyncio 0.17,
|
||||||
|
# which requires Python 3.7.
|
||||||
|
pytest_collection_modifyitems = _pytest_collection_modifyitems
|
||||||
|
|
||||||
|
|
||||||
@fixture(scope='module')
|
@fixture(scope='module')
|
||||||
def ssl_tmpdir(tmpdir_factory):
|
def ssl_tmpdir(tmpdir_factory):
|
||||||
return tmpdir_factory.mktemp('ssl')
|
return tmpdir_factory.mktemp('ssl')
|
||||||
|
@@ -3,6 +3,9 @@
|
|||||||
# so we have to disable this until pytest 3.11
|
# so we have to disable this until pytest 3.11
|
||||||
# minversion = 3.3
|
# minversion = 3.3
|
||||||
|
|
||||||
|
# automatically run coroutine tests with asyncio
|
||||||
|
asyncio_mode = auto
|
||||||
|
|
||||||
# jupyter_server plugin is incompatible with notebook imports
|
# jupyter_server plugin is incompatible with notebook imports
|
||||||
addopts = -p no:jupyter_server
|
addopts = -p no:jupyter_server
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user