Skip to content

Tracebacks from collection errors are not pruned #11710

@bluetech

Description

@bluetech

This is a regression in pytest 7.4 from commit fcada1e.

Given a test module

raise Exception('foo')

Expected output:

_______ ERROR collecting yy/test_y.py _______
yy/test_y.py:1: in <module>
    raise Exception('foo')
E   Exception: foo

Actual output:

_______ ERROR collecting yy/test_y.py _______
src/_pytest/runner.py:340: in from_call
    result: Optional[TResult] = func()
src/_pytest/runner.py:371: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
src/_pytest/python.py:579: in collect
    self._inject_setup_module_fixture()
src/_pytest/python.py:593: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
src/_pytest/python.py:307: in obj
    self._obj = obj = self._getobj()
src/_pytest/python.py:576: in _getobj
    return importtestmodule(self.path, self.config)
src/_pytest/python.py:528: in importtestmodule
    mod = import_path(path, mode=importmode, root=config.rootpath)
src/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
src/_pytest/assertion/rewrite.py:175: in exec_module
    exec(co, module.__dict__)
yy/test_y.py:1: in <module>
    raise Exception('foo')
E   Exception: foo

Metadata

Metadata

Assignees

Labels

topic: collectionrelated to the collection phasetopic: tracebacksrelated to displaying and handling of tracebackstype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions