You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This hook is executed after test collection and allows you to modify the list of collected items.
65
65
66
-
The function removes duplicate Doctest items.
66
+
The function removes
67
+
- duplicate Doctest items (e.g., scipy.stats.norm and scipy.stats.distributions.norm)
68
+
- Doctest items from underscored or otherwise private modules (e.g., scipy.special._precompute)
67
69
68
-
Doctest items are collected from all public modules, including the __all__ attribute in __init__.py.
69
-
This may lead to Doctest items being collected and tested more than once.
70
-
We therefore need to remove the duplicate items by creating a new list with only unique items.
70
+
Note that this functions cooperates with and cleans up after `DTModule.collect`, which does the
71
+
bulk of the collection work.
71
72
"""
73
+
# XXX: The logic in this function can probably be folded into DTModule.collect.
74
+
# I (E.B.) quickly tried it and it does not seem to just work. Apparently something
75
+
# pytest-y runs in between DTModule.collect and this hook (should that something
76
+
# be the proper home for all collection?)
77
+
72
78
ifconfig.getoption("--doctest-modules"):
73
-
seen_test_names=set()
74
79
unique_items= []
75
80
76
81
foriteminitems:
77
-
# Extract the item name, e.g., 'gauss_spline'
78
-
# Example item: <DoctestItem scipy.signal._bsplines.gauss_spline>
79
-
item_name=str(item).split('.')[-1].strip('>')
80
-
81
-
# In case the preceding string represents a function or a class,
82
-
# We need to keep the object name as both items represent different functions
83
-
# eg: <DoctestItem scipy.signal._ltisys.bode>
84
-
# <DoctestItem scipy.signal._ltisys.lti.bode>
85
-
obj_name=str(item).split('.')[-2]
86
-
87
-
# Extract the module path from the item's dtest attribute
88
-
# Example dtest: <DocTest scipy.signal.__init__.gauss_spline from /scipy/build-install/lib/python3.10/site-packages/scipy/signal/_bsplines.py:226 (5 examples)>
89
-
dtest=item.dtest
90
-
path=str(dtest).split(' ')[3].split(':')[0]
91
-
92
-
# Import the module to check if the object name is an attribute of the module
93
-
try:
94
-
module=import_path(
95
-
path,
96
-
root=config.rootpath,
97
-
mode=config.getoption("importmode"),
98
-
)
99
-
exceptImportError:
100
-
module=None
101
-
102
-
# Combine the module path, object name (if it exists) and item name to create a unique identifier
0 commit comments