File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -803,6 +803,15 @@ def formatrepr(self) -> FixtureLookupErrorRepr:
803803 stack = [self .request ._pyfuncitem .obj ]
804804 stack .extend (map (lambda x : x .func , self .fixturestack ))
805805 msg = self .msg
806+ # This function currently makes an assumption that a non-None msg means we
807+ # have a non-empty `self.fixturestack`. This is currently true, but if
808+ # somebody at some point want to extend the use of FixtureLookupError to
809+ # new cases it might break.
810+ # Add the assert to make it clearer to developer that this will fail, otherwise
811+ # it crashes because `fspath` does not get set due to `stack` being empty.
812+ assert (
813+ self .msg is None or self .fixturestack
814+ ), "formatrepr assumptions broken, rewrite it to handle it"
806815 if msg is not None :
807816 # The last fixture raise an error, let's present
808817 # it at the requesting side.
You can’t perform that action at this time.
0 commit comments