Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
unittest.expectedFailureIf
  • Loading branch information
youknowone committed Mar 1, 2023
commit 6d996834f33c4e24f13d5366f40dd488d1e05595
16 changes: 16 additions & 0 deletions Lib/unittest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)