Skip to content

Commit 2953de9

Browse files
committed
unittest.expectedFailureIf
1 parent a0472e1 commit 2953de9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/unittest/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,19 @@ def __getattr__(name):
9696
from .async_case import IsolatedAsyncioTestCase
9797
return IsolatedAsyncioTestCase
9898
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
99+
100+
101+
# XXX: RUSTPYTHON
102+
# This is very useful to reduce platform difference boilerplates in tests.
103+
def expectedFailureIf(condition, reason):
104+
assert reason.startswith("TODO: RUSTPYTHON")
105+
if condition:
106+
return expectedFailure
107+
else:
108+
return lambda x: x
109+
110+
# XXX: RUSTPYTHON
111+
# Even more useful because most of them are windows only.
112+
def expectedFailureIfWindows(reason):
113+
import sys
114+
return expectedFailureIf(sys.platform == 'win32', reason)

0 commit comments

Comments
 (0)