-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconftest.py
More file actions
34 lines (22 loc) · 836 Bytes
/
conftest.py
File metadata and controls
34 lines (22 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Config for doctests and test collection"""
from functools import lru_cache
import pytest
@pytest.fixture(autouse=True)
def add_standard_imports(doctest_namespace) -> None: # noqa: ARG001
import numpy as np
np.set_printoptions(precision=4)
@lru_cache
def _is_default_version() -> bool:
import sys
from pathlib import Path
return sys.version_info[:2] == tuple(
map(int, Path(".python-version").read_text(encoding="utf-8").strip().split("."))
)
def pytest_ignore_collect(collection_path) -> bool:
if not _is_default_version():
return "tmmc-lnpy/tests" not in str(collection_path)
return False
def pytest_collectstart(collector):
if collector.fspath and collector.fspath.ext == ".ipynb":
# Ignore stderr in comparison
collector.skip_compare += ("stderr",)