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 4
4
from _pytest .nodes import Collector
5
5
from _pytest .doctest import DoctestModule
6
6
7
+ from _pytest .pathlib import resolve_pkg_root_and_module_name
8
+ import importlib
9
+
7
10
# cysignals-CSI only works from gdb, i.e. invoke ./testgdb.py directly
8
11
collect_ignore = ["cysignals/cysignals-CSI-helper.py" ]
9
12
@@ -24,30 +27,10 @@ def pytest_collect_file(
24
27
config = parent .config
25
28
if file_path .suffix == ".pyx" :
26
29
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__
27
35
return DoctestModule .from_parent (parent , path = file_path )
28
36
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