File: conftest.py

package info (click to toggle)
python-transitions 0.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,728 kB
  • sloc: python: 8,765; makefile: 10; sh: 7
file content (22 lines) | stat: -rw-r--r-- 615 bytes parent folder | download
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