unittest.expectedFailureIf

This commit is contained in:
Jeong YunWon committed 2023-03-01 22:31:19 +09:00
1 parent e731e658ba
commit 6d996834f3
1 file changed
+16
+16
View File
@@ -96,3 +96,19 @@ def __getattr__(name):
from .async_case import IsolatedAsyncioTestCase
return IsolatedAsyncioTestCase
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
# XXX: RUSTPYTHON
# This is very useful to reduce platform difference boilerplates in tests.
def expectedFailureIf(condition, reason):
assert reason.startswith("TODO: RUSTPYTHON")
if condition:
return expectedFailure
else:
return lambda x: x
# XXX: RUSTPYTHON
# Even more useful because most of them are windows only.
def expectedFailureIfWindows(reason):
import sys
return expectedFailureIf(sys.platform == 'win32', reason)