Skip to content

Commit abfa4f3

Browse files
committed
use pytest.mark.xfail; add changelog entry
1 parent a42c3cd commit abfa4f3

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

changelog/7393.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unittest ``@expectedFailure`` marker with unexpected success outcome and if ``xfail_strict=False`` now translated to pytest's "XPASS" (was: "FAILED")

src/_pytest/unittest.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
from _pytest.python import PyCollector
3131
from _pytest.runner import CallInfo
3232
from _pytest.skipping import skipped_by_mark_key
33-
from _pytest.skipping import Xfail
34-
from _pytest.skipping import xfailed_key
3533

3634
if TYPE_CHECKING:
3735
import unittest
@@ -279,10 +277,7 @@ def addUnexpectedSuccess(
279277
msg = "Unexpected success"
280278
if reason:
281279
msg += f": {reason}"
282-
strict = self.config.getini("xfail_strict")
283-
self._store[xfailed_key] = Xfail(
284-
reason=msg, run=True, strict=strict, raises=None
285-
)
280+
self.add_marker(pytest.mark.xfail(reason=msg))
286281

287282
def addSuccess(self, testcase: "unittest.TestCase") -> None:
288283
pass

0 commit comments

Comments
 (0)