Skip to content

Commit

Permalink
remove usage of pytest CollectReport in rewrite (#21859)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eleanorjboyd committed Aug 21, 2023
1 parent 0749b20 commit cfbf1f3
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions pythonFiles/vscode_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ def __init__(self, message):


ERRORS = []
IS_DISCOVERY = False
map_id_to_path = dict()
collected_tests_so_far = list()


def pytest_load_initial_conftests(early_config, parser, args):
if "--collect-only" in args:
global IS_DISCOVERY
IS_DISCOVERY = True


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


IS_DISCOVERY = False
map_id_to_path = dict()


def pytest_load_initial_conftests(early_config, parser, args):
if "--collect-only" in args:
global IS_DISCOVERY
IS_DISCOVERY = True


collected_tests_so_far = list()


def pytest_report_teststatus(report, config):
"""
A pytest hook that is called when a test is called. It is called 3 times per test,
Expand Down

0 comments on commit cfbf1f3

Please sign in to comment.