File tree Expand file tree Collapse file tree 1 file changed +8
-25
lines changed Expand file tree Collapse file tree 1 file changed +8
-25
lines changed Original file line number Diff line number Diff line change 44from _pytest .nodes import Collector
55from _pytest .doctest import DoctestModule
66
7+ from _pytest .pathlib import resolve_pkg_root_and_module_name
8+ import importlib
9+
710# cysignals-CSI only works from gdb, i.e. invoke ./testgdb.py directly
811collect_ignore = ["cysignals/cysignals-CSI-helper.py" ]
912
@@ -24,30 +27,10 @@ def pytest_collect_file(
2427 config = parent .config
2528 if file_path .suffix == ".pyx" :
2629 if config .option .doctestmodules :
30+ # import the module so it's available to pytest
31+ _ , module_name = resolve_pkg_root_and_module_name (file_path )
32+ module = importlib .import_module (module_name )
33+ # delete __test__ injected by cython, to avoid duplicate tests
34+ del module .__test__
2735 return DoctestModule .from_parent (parent , path = file_path )
2836 return None
29-
30-
31- # Need to import cysignals to initialize it
32- import cysignals # noqa: E402
33-
34- try :
35- import cysignals .alarm
36- except ImportError :
37- pass
38- try :
39- import cysignals .signals
40- except ImportError :
41- pass
42- try :
43- import cysignals .pselect
44- except ImportError :
45- pass
46- try :
47- import cysignals .pysignals
48- except ImportError :
49- pass
50- try :
51- import cysignals .tests # noqa: F401
52- except ImportError :
53- pass
You can’t perform that action at this time.
0 commit comments