hy/conftest.py

19 lines
700 B
Python
Raw Normal View History

2017-04-26 23:00:11 +02:00
import _pytest
import hy
2017-08-31 07:36:06 +02:00
import os
2017-12-30 23:31:06 +01:00
from hy._compat import PY3, PY35, PY36
2017-04-26 23:00:11 +02:00
2017-08-31 07:36:06 +02:00
NATIVE_TESTS = os.path.join("", "tests", "native_tests", "")
2017-04-26 23:00:11 +02:00
def pytest_collect_file(parent, path):
if (path.ext == ".hy"
2017-08-31 07:36:06 +02:00
and NATIVE_TESTS in path.dirname + os.sep
2017-04-26 23:00:11 +02:00
and path.basename != "__init__.hy"
2017-07-17 22:34:39 +02:00
and not ("py3_only" in path.basename and not PY3)
2017-12-30 23:31:06 +01:00
and not ("py35_only" in path.basename and not PY35)
and not ("py36_only" in path.basename and not PY36)):
2017-04-26 23:00:11 +02:00
m = _pytest.python.pytest_pycollect_makemodule(path, parent)
# Spoof the module name to avoid hitting an assertion in pytest.
m.name = m.name[:-len(".hy")] + ".py"
return m