Skip to content

Add unittset.expectedFailureIf for RustPython #4597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 3 additions & 10 deletions Lib/test/test_charmapcodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def codec_search_function(encoding):
codecname = 'testcodec'

class CharmapCodecTest(unittest.TestCase):
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_constructorx(self):
self.assertEqual(str(b'abc', codecname), 'abc')
self.assertEqual(str(b'xdef', codecname), 'abcdef')
Expand All @@ -42,24 +43,16 @@ def test_encodex(self):
self.assertEqual('dxf'.encode(codecname), b'dabcf')
self.assertEqual('dxfx'.encode(codecname), b'dabcfabc')

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_constructory(self):
self.assertEqual(str(b'ydef', codecname), 'def')
self.assertEqual(str(b'defy', codecname), 'def')
self.assertEqual(str(b'dyf', codecname), 'df')
self.assertEqual(str(b'dyfy', codecname), 'df')

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_maptoundefined(self):
self.assertRaises(UnicodeError, str, b'abc\001', codecname)

# TODO: RUSTPYTHON
import sys
if sys.platform == "win32":
# TODO: RUSTPYTHON
test_constructorx = unittest.expectedFailure(test_constructorx)
# TODO: RUSTPYTHON
test_constructory = unittest.expectedFailure(test_constructory)
# TODO: RUSTPYTHON
test_maptoundefined = unittest.expectedFailure(test_maptoundefined)

if __name__ == "__main__":
unittest.main()
71 changes: 14 additions & 57 deletions Lib/test/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,7 @@ def test_decode(self):
self.assertEqual(codecs.decode(b'[\xff]', 'ascii', errors='ignore'),
'[]')

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_encode(self):
self.assertEqual(codecs.encode('\xe4\xf6\xfc', 'latin-1'),
b'\xe4\xf6\xfc')
Expand All @@ -1807,14 +1808,11 @@ def test_encode(self):
self.assertEqual(codecs.encode('[\xff]', 'ascii', errors='ignore'),
b'[]')

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_encode = unittest.expectedFailure(test_encode)

def test_register(self):
self.assertRaises(TypeError, codecs.register)
self.assertRaises(TypeError, codecs.register, 42)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AttributeError: module '_winapi' has no attribute 'GetACP'")
def test_unregister(self):
name = "nonexistent_codec_name"
search_function = mock.Mock()
Expand All @@ -1827,51 +1825,32 @@ def test_unregister(self):
self.assertRaises(LookupError, codecs.lookup, name)
search_function.assert_not_called()

# TODO: RUSTPYTHON, AttributeError: module '_winapi' has no attribute 'GetACP'
if sys.platform == "win32":
test_unregister = unittest.expectedFailure(test_unregister)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_lookup(self):
self.assertRaises(TypeError, codecs.lookup)
self.assertRaises(LookupError, codecs.lookup, "__spam__")
self.assertRaises(LookupError, codecs.lookup, " ")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_lookup = unittest.expectedFailure(test_lookup)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getencoder(self):
self.assertRaises(TypeError, codecs.getencoder)
self.assertRaises(LookupError, codecs.getencoder, "__spam__")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_getencoder = unittest.expectedFailure(test_getencoder)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getdecoder(self):
self.assertRaises(TypeError, codecs.getdecoder)
self.assertRaises(LookupError, codecs.getdecoder, "__spam__")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_getdecoder = unittest.expectedFailure(test_getdecoder)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getreader(self):
self.assertRaises(TypeError, codecs.getreader)
self.assertRaises(LookupError, codecs.getreader, "__spam__")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_getreader = unittest.expectedFailure(test_getreader)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_getwriter(self):
self.assertRaises(TypeError, codecs.getwriter)
self.assertRaises(LookupError, codecs.getwriter, "__spam__")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_getwriter = unittest.expectedFailure(test_getwriter)

def test_lookup_issue1813(self):
# Issue #1813: under Turkish locales, lookup of some codecs failed
# because 'I' is lowercased as "ı" (dotless i)
Expand Down Expand Up @@ -1926,6 +1905,7 @@ def test_undefined(self):
self.assertRaises(UnicodeError,
codecs.decode, b'abc', 'undefined', errors)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_file_closes_if_lookup_error_raised(self):
mock_open = mock.mock_open()
with mock.patch('builtins.open', mock_open) as file:
Expand All @@ -1934,11 +1914,6 @@ def test_file_closes_if_lookup_error_raised(self):

file().close.assert_called()

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_file_closes_if_lookup_error_raised = unittest.expectedFailure(test_file_closes_if_lookup_error_raised)


class StreamReaderTest(unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -3190,51 +3165,37 @@ def raise_obj(*args, **kwds):
with self.assertRaisesRegex(RuntimeError, msg):
codecs.decode(b"bytes input", self.codec_name)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_init_override_is_not_wrapped(self):
class CustomInit(RuntimeError):
def __init__(self):
pass
self.check_not_wrapped(CustomInit, "")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_init_override_is_not_wrapped = unittest.expectedFailure(test_init_override_is_not_wrapped)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_new_override_is_not_wrapped(self):
class CustomNew(RuntimeError):
def __new__(cls):
return super().__new__(cls)
self.check_not_wrapped(CustomNew, "")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_new_override_is_not_wrapped = unittest.expectedFailure(test_new_override_is_not_wrapped)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_instance_attribute_is_not_wrapped(self):
msg = "This should NOT be wrapped"
exc = RuntimeError(msg)
exc.attr = 1
self.check_not_wrapped(exc, "^{}$".format(msg))

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_instance_attribute_is_not_wrapped = unittest.expectedFailure(test_instance_attribute_is_not_wrapped)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_non_str_arg_is_not_wrapped(self):
self.check_not_wrapped(RuntimeError(1), "1")

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_non_str_arg_is_not_wrapped = unittest.expectedFailure(test_non_str_arg_is_not_wrapped)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_multiple_args_is_not_wrapped(self):
msg_re = r"^\('a', 'b', 'c'\)$"
self.check_not_wrapped(RuntimeError('a', 'b', 'c'), msg_re)

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_multiple_args_is_not_wrapped = unittest.expectedFailure(test_multiple_args_is_not_wrapped)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
# http://bugs.python.org/issue19609
def test_codec_lookup_failure_not_wrapped(self):
msg = "^unknown encoding: {}$".format(self.codec_name)
Expand All @@ -3248,10 +3209,6 @@ def test_codec_lookup_failure_not_wrapped(self):
with self.assertRaisesRegex(LookupError, msg):
codecs.decode(b"bytes input", self.codec_name)

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_codec_lookup_failure_not_wrapped = unittest.expectedFailure(test_codec_lookup_failure_not_wrapped)

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_unflagged_non_text_codec_handling(self):
Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_difflib.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_mdiff_catch_stop_iteration(self):
the end"""

class TestSFpatches(unittest.TestCase):

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_html_diff(self):
# Check SF patch 914575 for generating HTML differences
f1a = ((patch914575_from1 + '123\n'*10)*3)
Expand Down Expand Up @@ -244,10 +244,6 @@ def test_html_diff(self):
with open(findfile('test_difflib_expect.html')) as fp:
self.assertEqual(actual, fp.read())

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_html_diff = unittest.expectedFailure(test_html_diff)

def test_recursion_limit(self):
# Check if the problem described in patch #1413711 exists.
limit = sys.getrecursionlimit()
Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_exception_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def _make_map(s):
return _map
_map = _make_map(_pep_map)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_errno_mapping(self):
# The OSError constructor maps errnos to subclasses
# A sample test for the basic functionality
Expand All @@ -94,11 +95,6 @@ def test_errno_mapping(self):
e = OSError(errcode, "Some message")
self.assertIs(type(e), OSError)

# TODO: RUSTPYTHON
import sys
if sys.platform == 'win32':
test_errno_mapping = unittest.expectedFailure(test_errno_mapping)

def test_try_except(self):
filename = "some_hopefully_non_existing_file"

Expand Down
4 changes: 1 addition & 3 deletions Lib/test/test_faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def test_enable_single_thread(self):
'Segmentation fault',
all_threads=False)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AttributeError: module 'msvcrt' has no attribute 'GetErrorMode'")
@skip_segfault_on_android
def test_disable(self):
code = """
Expand All @@ -383,9 +384,6 @@ def test_disable(self):
"%r is present in %r" % (not_expected, stderr))
self.assertNotEqual(exitcode, 0)

if sys.platform == "win32": # TODO: RUSTPYTHON, AttributeError: module 'msvcrt' has no attribute 'GetErrorMode'
test_disable = unittest.expectedFailure(test_disable)

# TODO: RUSTPYTHON
@unittest.expectedFailure
@skip_segfault_on_android
Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,6 @@ def testMethods(self):
self.assertRaises(ValueError, self.f.writelines, b'')

def testOpendir(self):
# TODO: RUSTPYTHON
if sys.platform == "win32":
testOpendir = unittest.expectedFailure(testOpendir)
# Issue 3703: opening a directory should fill the errno
# Windows always returns "[Errno 13]: Permission denied
# Unix uses fstat and returns "[Errno 21]: Is a directory"
Expand Down Expand Up @@ -381,8 +378,7 @@ def testMethods(self):
def testOpenDirFD(self):
super().testOpenDirFD()

# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailureIf(sys.platform != "win32", "TODO: RUSTPYTHON")
def testOpendir(self):
super().testOpendir()

Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_fnmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,12 @@ def test_fnmatchcase(self):
check('usr/bin', 'usr\\bin', False, fnmatchcase)
check('usr\\bin', 'usr\\bin', True, fnmatchcase)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_bytes(self):
self.check_match(b'test', b'te*')
self.check_match(b'test\xff', b'te*\xff')
self.check_match(b'foo\nbar', b'foo*')

# TODO: RUSTPYTHON
import sys
if sys.platform == 'win32':
test_bytes = unittest.expectedFailure(test_bytes)

def test_case(self):
ignorecase = os.path.normcase('ABC') == os.path.normcase('abc')
check = self.check_match
Expand Down
10 changes: 2 additions & 8 deletions Lib/test/test_genericpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,11 @@ def _test_samefile_on_link_func(self, func):
create_file(test_fn2)
self.assertFalse(self.pathmodule.samefile(test_fn1, test_fn2))

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; properly implement stat st_dev/st_ino")
@os_helper.skip_unless_symlink
def test_samefile_on_symlink(self):
self._test_samefile_on_link_func(os.symlink)

if sys.platform == 'win32':
# TODO: RUSTPYTHON, properly implement stat st_dev/st_ino
test_samefile_on_symlink = unittest.expectedFailure(test_samefile_on_symlink)

def test_samefile_on_link(self):
try:
self._test_samefile_on_link_func(os.link)
Expand Down Expand Up @@ -288,14 +285,11 @@ def _test_samestat_on_link_func(self, func):
self.assertFalse(self.pathmodule.samestat(os.stat(test_fn1),
os.stat(test_fn2)))

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; properly implement stat st_dev/st_ino")
@os_helper.skip_unless_symlink
def test_samestat_on_symlink(self):
self._test_samestat_on_link_func(os.symlink)

if sys.platform == 'win32':
# TODO: RUSTPYTHON, properly implement stat st_dev/st_ino
test_samestat_on_symlink = unittest.expectedFailure(test_samestat_on_symlink)

def test_samestat_on_link(self):
try:
self._test_samestat_on_link_func(os.link)
Expand Down
6 changes: 1 addition & 5 deletions Lib/test/test_gzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ def test_bad_params(self):
with self.assertRaises(ValueError):
gzip.open(self.filename, "rb", newline="\n")

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_encoding(self):
# Test non-default encoding.
uncompressed = data1.decode("ascii") * 50
Expand All @@ -720,11 +721,6 @@ def test_encoding(self):
with gzip.open(self.filename, "rt", encoding="utf-16") as f:
self.assertEqual(f.read(), uncompressed)

# TODO: RUSTPYTHON
if sys.platform == "win32":
test_encoding = unittest.expectedFailure(test_encoding)


def test_encoding_error_handler(self):
# Test with non-default encoding error handler.
with gzip.open(self.filename, "wb") as f:
Expand Down
5 changes: 1 addition & 4 deletions Lib/test/test_imp.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def test_find_module_encoding(self):
with self.assertRaises(SyntaxError):
imp.find_module('badsyntax_pep3120', path)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_issue1267(self):
for mod, encoding, _ in self.test_strings:
fp, filename, info = imp.find_module('module_' + mod,
Expand All @@ -100,10 +101,6 @@ def test_issue1267(self):
self.assertEqual(fp.readline(),
'"""Tokenization help for Python programs.\n')

# TODO: RUSTPYTHON
if sys.platform == 'win32':
test_issue1267 = unittest.expectedFailure(test_issue1267)

def test_issue3594(self):
temp_mod_name = 'test_imp_helper'
sys.path.insert(0, '.')
Expand Down
5 changes: 1 addition & 4 deletions Lib/test/test_importlib/source/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def test_no_read_directory(self):
found = self._find(finder, 'doesnotexist')
self.assertEqual(found, self.NOT_FOUND)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
def test_ignore_file(self):
# If a directory got changed to a file from underneath us, then don't
# worry about looking for submodules.
Expand All @@ -176,10 +177,6 @@ def test_ignore_file(self):
found = self._find(finder, 'doesnotexist')
self.assertEqual(found, self.NOT_FOUND)

# TODO: RUSTPYTHON
if sys.platform == 'win32':
test_ignore_file = unittest.expectedFailure(test_ignore_file)


class FinderTestsPEP451(FinderTests):

Expand Down
Loading