Skip to content

Commit

Permalink
Merge pull request #220 from tornaria/__test__
Browse files Browse the repository at this point in the history
dont run repeated tests from cython __test__ dict
  • Loading branch information
dimpase authored Jan 23, 2025
2 parents 95ed336 + 114c999 commit 3cf5e38
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions src/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from _pytest.nodes import Collector
from _pytest.doctest import DoctestModule

from _pytest.pathlib import resolve_pkg_root_and_module_name
import importlib

# cysignals-CSI only works from gdb, i.e. invoke ./testgdb.py directly
collect_ignore = ["cysignals/cysignals-CSI-helper.py"]

Expand All @@ -24,30 +27,10 @@ def pytest_collect_file(
config = parent.config
if file_path.suffix == ".pyx":
if config.option.doctestmodules:
# import the module so it's available to pytest
_, module_name = resolve_pkg_root_and_module_name(file_path)
module = importlib.import_module(module_name)
# delete __test__ injected by cython, to avoid duplicate tests
del module.__test__
return DoctestModule.from_parent(parent, path=file_path)
return None


# Need to import cysignals to initialize it
import cysignals # noqa: E402

try:
import cysignals.alarm
except ImportError:
pass
try:
import cysignals.signals
except ImportError:
pass
try:
import cysignals.pselect
except ImportError:
pass
try:
import cysignals.pysignals
except ImportError:
pass
try:
import cysignals.tests # noqa: F401
except ImportError:
pass

0 comments on commit 3cf5e38

Please sign in to comment.