1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
"""
pytest configuration - Tests async functionality only when asyncio and contextvars are available (Python 3.7+)
"""
# imports are required to check whether the modules are available
# pylint: disable=unused-import
from os.path import basename
try:
import asyncio
import contextvars
WITH_ASYNC = True
except ImportError:
WITH_ASYNC = False
async_files = ['test_async.py', 'asyncio.py']
def pytest_ignore_collect(collection_path):
"""Text collection function executed by pytest"""
if not WITH_ASYNC and basename(str(collection_path)) in async_files:
return True
return None
|