MCPcopy Create free account
hub / github.com/pytest-dev/pytest / addUnexpectedSuccess

Method addUnexpectedSuccess

src/_pytest/unittest.py:272–284  ·  view source on GitHub ↗
(
        self,
        testcase: "unittest.TestCase",
        reason: Optional["twisted.trial.unittest.Todo"] = None,
    )

Source from the content-addressed store, hash-verified

270 self._addexcinfo(sys.exc_info())
271
272 def addUnexpectedSuccess(
273 self,
274 testcase: "unittest.TestCase",
275 reason: Optional["twisted.trial.unittest.Todo"] = None,
276 ) -> None:
277 msg = "Unexpected success"
278 if reason:
279 msg += f": {reason.reason}"
280 # Preserve unittest behaviour - fail the test. Explicitly not an XPASS.
281 try:
282 fail(msg, pytrace=False)
283 except fail.Exception:
284 self._addexcinfo(sys.exc_info())
285
286 def addSuccess(self, testcase: "unittest.TestCase") -> None:
287 pass

Callers

nothing calls this directly

Calls 2

_addexcinfoMethod · 0.95
failFunction · 0.90

Tested by

no test coverage detected