@@ -46,6 +46,15 @@ def __init__(self, message):
46
46
47
47
48
48
ERRORS = []
49
+ IS_DISCOVERY = False
50
+ map_id_to_path = dict ()
51
+ collected_tests_so_far = list ()
52
+
53
+
54
+ def pytest_load_initial_conftests (early_config , parser , args ):
55
+ if "--collect-only" in args :
56
+ global IS_DISCOVERY
57
+ IS_DISCOVERY = True
49
58
50
59
51
60
def pytest_internalerror (excrepr , excinfo ):
@@ -70,7 +79,7 @@ def pytest_exception_interact(node, call, report):
70
79
# call.excinfo is the captured exception of the call, if it raised as type ExceptionInfo.
71
80
# call.excinfo.exconly() returns the exception as a string.
72
81
# If it is during discovery, then add the error to error logs.
73
- if type ( report ) == pytest . CollectReport :
82
+ if IS_DISCOVERY :
74
83
if call .excinfo and call .excinfo .typename != "AssertionError" :
75
84
if report .outcome == "skipped" and "SkipTest" in str (call ):
76
85
return
@@ -168,19 +177,6 @@ class testRunResultDict(Dict[str, Dict[str, TestOutcome]]):
168
177
tests : Dict [str , TestOutcome ]
169
178
170
179
171
- IS_DISCOVERY = False
172
- map_id_to_path = dict ()
173
-
174
-
175
- def pytest_load_initial_conftests (early_config , parser , args ):
176
- if "--collect-only" in args :
177
- global IS_DISCOVERY
178
- IS_DISCOVERY = True
179
-
180
-
181
- collected_tests_so_far = list ()
182
-
183
-
184
180
def pytest_report_teststatus (report , config ):
185
181
"""
186
182
A pytest hook that is called when a test is called. It is called 3 times per test,
0 commit comments