mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-07 10:04:07 +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
|
||||
pre-commit
|
||||
pytest>=3.3
|
||||
pytest-asyncio
|
||||
pytest-asyncio; python_version < "3.7"
|
||||
pytest-asyncio>=0.17; python_version >= "3.7"
|
||||
pytest-cov
|
||||
requests-mock
|
||||
tbump
|
||||
|
@@ -59,12 +59,14 @@ from .utils import add_user
|
||||
_db = None
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(items):
|
||||
def _pytest_collection_modifyitems(items):
|
||||
"""This function is automatically run by pytest passing all collected test
|
||||
functions.
|
||||
|
||||
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.
|
||||
|
||||
It is no longer required with pytest-asyncio >= 0.17
|
||||
"""
|
||||
for item in items:
|
||||
if inspect.iscoroutinefunction(item.obj):
|
||||
@@ -72,6 +74,13 @@ def pytest_collection_modifyitems(items):
|
||||
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')
|
||||
def ssl_tmpdir(tmpdir_factory):
|
||||
return tmpdir_factory.mktemp('ssl')
|
||||
|
@@ -3,6 +3,9 @@
|
||||
# so we have to disable this until pytest 3.11
|
||||
# minversion = 3.3
|
||||
|
||||
# automatically run coroutine tests with asyncio
|
||||
asyncio_mode = auto
|
||||
|
||||
# jupyter_server plugin is incompatible with notebook imports
|
||||
addopts = -p no:jupyter_server
|
||||
|
||||
|
Reference in New Issue
Block a user