Skip to content

Commit cfbf1f3

Browse files
authored
remove usage of pytest CollectReport in rewrite (#21859)
as per https://docs.pytest.org/en/7.1.x/reference/reference.html#collectreport, `CollectReport` is experimental and therefore it should not be in our extension. Fixes #21784
1 parent 0749b20 commit cfbf1f3

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

pythonFiles/vscode_pytest/__init__.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def __init__(self, message):
4646

4747

4848
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
4958

5059

5160
def pytest_internalerror(excrepr, excinfo):
@@ -70,7 +79,7 @@ def pytest_exception_interact(node, call, report):
7079
# call.excinfo is the captured exception of the call, if it raised as type ExceptionInfo.
7180
# call.excinfo.exconly() returns the exception as a string.
7281
# If it is during discovery, then add the error to error logs.
73-
if type(report) == pytest.CollectReport:
82+
if IS_DISCOVERY:
7483
if call.excinfo and call.excinfo.typename != "AssertionError":
7584
if report.outcome == "skipped" and "SkipTest" in str(call):
7685
return
@@ -168,19 +177,6 @@ class testRunResultDict(Dict[str, Dict[str, TestOutcome]]):
168177
tests: Dict[str, TestOutcome]
169178

170179

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-
184180
def pytest_report_teststatus(report, config):
185181
"""
186182
A pytest hook that is called when a test is called. It is called 3 times per test,

0 commit comments

Comments
 (0)