Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,15 @@
stack = [self.request._pyfuncitem.obj]
stack.extend(map(lambda x: x.func, self.fixturestack))
msg = self.msg
# This function currently makes an assumption that a non-None msg means we
# have a non-empty `self.fixturestack`. This is currently true, but if
# somebody at some point want to extend the use of FixtureLookupError to
# new cases it might break.
# Add the assert to make it clearer to developer that this will fail, otherwise
# it crashes because `fspath` does not get set due to `stack` being empty.
assert (

Check warning on line 814 in src/_pytest/fixtures.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/fixtures.py#L814

Added line #L814 was not covered by tests
self.msg is None or self.fixturestack
), "formatrepr assumptions broken, rewrite it to handle it"
if msg is not None:
# The last fixture raise an error, let's present
# it at the requesting side.
Expand Down
Loading