forked from hylang/hy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
41 lines (32 loc) · 913 Bytes
/
conftest.py
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
35
36
37
38
39
40
41
import importlib
import os
import sys
from functools import reduce
from operator import or_
from pathlib import Path
import pytest
import hy
from hy._compat import PY3_8, PY3_10
NATIVE_TESTS = os.path.join("", "tests", "native_tests", "")
# https://github.com/hylang/hy/issues/2029
os.environ.pop("HYSTARTUP", None)
def pytest_ignore_collect(path, config):
versions = [
(sys.version_info < (3, 8), "sub_py3_7_only"),
(PY3_8, "py3_8_only"),
(PY3_10, "py3_10_only"),
]
return (
reduce(
or_,
(name in path.basename and not condition for condition, name in versions),
)
or None
)
def pytest_collect_file(parent, path):
if (
path.ext == ".hy"
and NATIVE_TESTS in path.dirname + os.sep
and path.basename != "__init__.hy"
):
return pytest.Module.from_parent(parent, path=Path(path))