From 6d996834f33c4e24f13d5366f40dd488d1e05595 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Wed, 1 Mar 2023 04:58:48 +0900 Subject: [PATCH 1/2] unittest.expectedFailureIf --- Lib/unittest/__init__.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py index 005d23f6d0..7ab3f5e87b 100644 --- a/Lib/unittest/__init__.py +++ b/Lib/unittest/__init__.py @@ -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) From 367a948ff0defed02de6619220640d386e1095c6 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Wed, 1 Mar 2023 05:30:41 +0900 Subject: [PATCH 2/2] Adapt unittest.expectedFailureIf --- Lib/test/test_charmapcodec.py | 13 +--- Lib/test/test_codecs.py | 71 ++++--------------- Lib/test/test_difflib.py | 6 +- Lib/test/test_exception_hierarchy.py | 6 +- Lib/test/test_faulthandler.py | 4 +- Lib/test/test_fileio.py | 6 +- Lib/test/test_fnmatch.py | 6 +- Lib/test/test_genericpath.py | 10 +-- Lib/test/test_gzip.py | 6 +- Lib/test/test_imp.py | 5 +- Lib/test/test_importlib/source/test_finder.py | 5 +- .../test_importlib/test_threaded_import.py | 5 +- Lib/test/test_locale.py | 10 +-- Lib/test/test_ntpath.py | 25 ++----- Lib/test/test_platform.py | 5 +- Lib/test/test_popen.py | 10 +-- Lib/test/test_posixpath.py | 10 +-- Lib/test/test_py_compile.py | 17 ++--- Lib/test/test_runpy.py | 19 ++--- Lib/test/test_selectors.py | 5 +- Lib/test/test_signal.py | 20 ++---- Lib/test/test_socket.py | 10 +-- Lib/test/test_socketserver.py | 25 ++----- Lib/test/test_strftime.py | 5 +- Lib/test/test_subprocess.py | 35 ++------- Lib/test/test_sundry.py | 5 +- Lib/test/test_support.py | 6 +- Lib/test/test_sysconfig.py | 19 +---- Lib/test/test_tarfile.py | 50 +++---------- Lib/test/test_tempfile.py | 5 +- Lib/test/test_tokenize.py | 12 +--- Lib/test/test_utf8_mode.py | 10 +-- 32 files changed, 90 insertions(+), 356 deletions(-) diff --git a/Lib/test/test_charmapcodec.py b/Lib/test/test_charmapcodec.py index cd7a35d696..e69f1c6e4b 100644 --- a/Lib/test/test_charmapcodec.py +++ b/Lib/test/test_charmapcodec.py @@ -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') @@ -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() diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index fa826f247c..ae9449f11e 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -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') @@ -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() @@ -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) @@ -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: @@ -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): @@ -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) @@ -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): diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py index 68da83dda2..208208fd68 100644 --- a/Lib/test/test_difflib.py +++ b/Lib/test/test_difflib.py @@ -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) @@ -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() diff --git a/Lib/test/test_exception_hierarchy.py b/Lib/test/test_exception_hierarchy.py index 85a7dd8b2a..a4f10f850f 100644 --- a/Lib/test/test_exception_hierarchy.py +++ b/Lib/test/test_exception_hierarchy.py @@ -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 @@ -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" diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py index 5e73f7381e..533203cfe5 100644 --- a/Lib/test/test_faulthandler.py +++ b/Lib/test/test_faulthandler.py @@ -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 = """ @@ -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 diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py index f878fce1dc..200b8ce773 100644 --- a/Lib/test/test_fileio.py +++ b/Lib/test/test_fileio.py @@ -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" @@ -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() diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py index 04365341d8..092cd56285 100644 --- a/Lib/test/test_fnmatch.py +++ b/Lib/test/test_fnmatch.py @@ -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 diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py index 01363c3bb5..aef6bf9d16 100644 --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -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) @@ -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) diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 2b84beaf36..546f91bb7d 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -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 @@ -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: diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index f06a120d3c..9b602582e2 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -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, @@ -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, '.') diff --git a/Lib/test/test_importlib/source/test_finder.py b/Lib/test/test_importlib/source/test_finder.py index 73ef8bf961..3c12ab0123 100644 --- a/Lib/test/test_importlib/source/test_finder.py +++ b/Lib/test/test_importlib/source/test_finder.py @@ -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. @@ -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): diff --git a/Lib/test/test_importlib/test_threaded_import.py b/Lib/test/test_importlib/test_threaded_import.py index 3c143ad37f..c131952181 100644 --- a/Lib/test/test_importlib/test_threaded_import.py +++ b/Lib/test/test_importlib/test_threaded_import.py @@ -260,16 +260,13 @@ def test_concurrent_futures_circular_import(self): 'partial', 'cfimport.py') script_helper.assert_python_ok(fn) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_multiprocessing_pool_circular_import(self): # Regression test for bpo-41567 fn = os.path.join(os.path.dirname(__file__), 'partial', 'pool_in_threads.py') script_helper.assert_python_ok(fn) - # TODO: RUSTPYTHON - if sys.platform == 'win32': - test_multiprocessing_pool_circular_import = unittest.expectedFailure(test_multiprocessing_pool_circular_import) - def setUpModule(): thread_info = threading_helper.threading_setup() diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py index fff605d9b6..55f60b2dc3 100644 --- a/Lib/test/test_locale.py +++ b/Lib/test/test_locale.py @@ -510,6 +510,7 @@ def test_japanese(self): class TestMiscellaneous(unittest.TestCase): + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_defaults_UTF8(self): # Issue #18378: on (at least) macOS setting LC_CTYPE to "UTF-8" is # valid. Furthermore LC_CTYPE=UTF is used by the UTF-8 locale coercing @@ -546,10 +547,6 @@ def test_defaults_UTF8(self): if orig_getlocale is not None: _locale._getdefaultlocale = orig_getlocale - - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_defaults_UTF8 = unittest.expectedFailure(test_defaults_UTF8) def test_getencoding(self): # Invoke getencoding to make sure it does not cause exceptions. @@ -571,6 +568,7 @@ def test_strcoll_3303(self): self.assertRaises(TypeError, locale.strcoll, "a", None) self.assertRaises(TypeError, locale.strcoll, b"a", None) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_setlocale_category(self): locale.setlocale(locale.LC_ALL) locale.setlocale(locale.LC_TIME) @@ -581,10 +579,6 @@ def test_setlocale_category(self): # crasher from bug #7419 self.assertRaises(locale.Error, locale.setlocale, 12345) - - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_setlocale_category = unittest.expectedFailure(test_setlocale_category) def test_getsetlocale_issue1813(self): # Issue #1813: setting and getting the locale under a Turkish locale diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 19ffdf5702..969a05030a 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -508,6 +508,7 @@ def test_realpath_cwd(self): with os_helper.change_cwd(test_dir_short): self.assertPathEqual(test_file_long, ntpath.realpath("file.txt")) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; ValueError: illegal environment variable name") def test_expandvars(self): with os_helper.EnvironmentVarGuard() as env: env.clear() @@ -534,10 +535,7 @@ def test_expandvars(self): tester('ntpath.expandvars("\'%foo%\'%bar")', "\'%foo%\'%bar") tester('ntpath.expandvars("bar\'%foo%")', "bar\'%foo%") - # TODO: RUSTPYTHON, ValueError: illegal environment variable name - if sys.platform == 'win32': - test_expandvars = unittest.expectedFailure(test_expandvars) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; ValueError: illegal environment variable name") @unittest.skipUnless(os_helper.FS_NONASCII, 'need os_helper.FS_NONASCII') def test_expandvars_nonascii(self): def check(value, expected): @@ -558,10 +556,7 @@ def check(value, expected): check('%spam%bar', '%sbar' % nonascii) check('%{}%bar'.format(nonascii), 'ham%sbar' % nonascii) - # TODO: RUSTPYTHON, ValueError: illegal environment variable name - if sys.platform == 'win32': - test_expandvars_nonascii = unittest.expectedFailure(test_expandvars_nonascii) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_expanduser(self): tester('ntpath.expanduser("test")', 'test') @@ -609,10 +604,6 @@ def test_expanduser(self): tester('ntpath.expanduser("~test")', '~test') tester('ntpath.expanduser("~")', 'C:\\Users\\eric') - # TODO: RUSTPYTHON - if sys.platform == 'win32': - test_expanduser = unittest.expectedFailure(test_expanduser) - @unittest.skipUnless(nt, "abspath requires 'nt' module") def test_abspath(self): tester('ntpath.abspath("C:\\")', "C:\\") @@ -716,6 +707,7 @@ def check_error(exc, paths): self.assertRaises(TypeError, ntpath.commonpath, ['Program Files', b'C:\\Program Files\\Foo']) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_sameopenfile(self): with TemporaryFile() as tf1, TemporaryFile() as tf2: # Make sure the same file is really the same @@ -729,10 +721,6 @@ def test_sameopenfile(self): # dialogs (#4804) ntpath.sameopenfile(-1, -1) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_sameopenfile = unittest.expectedFailure(test_sameopenfile) - def test_ismount(self): self.assertTrue(ntpath.ismount("c:\\")) self.assertTrue(ntpath.ismount("C:\\")) @@ -859,15 +847,12 @@ def setUp(self): def _check_function(self, func): self.assertPathEqual(func(self.file_path), func(self.file_name)) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: 'ωω' != 'ωΩ'") def test_path_normcase(self): self._check_function(self.path.normcase) if sys.platform == 'win32': self.assertEqual(ntpath.normcase('\u03a9\u2126'), 'ωΩ') - # TODO: RUSTPYTHON, AssertionError: 'ωω' != 'ωΩ' - if sys.platform == "win32": - test_path_normcase = unittest.expectedFailure(test_path_normcase) - def test_path_isabs(self): self._check_function(self.path.isabs) diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py index 82d3e82c88..0d2a04c795 100644 --- a/Lib/test/test_platform.py +++ b/Lib/test/test_platform.py @@ -78,16 +78,13 @@ def clear_caches(self): def test_architecture(self): res = platform.architecture() + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") @os_helper.skip_unless_symlink def test_architecture_via_symlink(self): # issue3762 with support.PythonSymlink() as py: cmd = "-c", "import platform; print(platform.architecture())" self.assertEqual(py.call_real(*cmd), py.call_link(*cmd)) - # TODO: RUSTPYTHON; _winapi.GetModuleFileName - if sys.platform == 'win32': - test_architecture_via_symlink = unittest.expectedFailure(test_architecture_via_symlink) - def test_platform(self): for aliased in (False, True): for terse in (False, True): diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py index 41db7b3b63..63406b1382 100644 --- a/Lib/test/test_popen.py +++ b/Lib/test/test_popen.py @@ -53,22 +53,16 @@ def test_return_code(self): else: self.assertEqual(os.waitstatus_to_exitcode(status), 42) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_contextmanager(self): with os.popen("echo hello") as f: self.assertEqual(f.read(), "hello\n") - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_contextmanager = unittest.expectedFailure(test_contextmanager) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_iterating(self): with os.popen("echo hello") as f: self.assertEqual(list(f), ["hello\n"]) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_iterating = unittest.expectedFailure(test_iterating) - def test_keywords(self): with os.popen(cmd="exit 0", mode="w", buffering=-1): pass diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py index a017c967b3..ab36d20540 100644 --- a/Lib/test/test_posixpath.py +++ b/Lib/test/test_posixpath.py @@ -154,6 +154,7 @@ def test_dirname(self): self.assertEqual(posixpath.dirname(b"////foo"), b"////") self.assertEqual(posixpath.dirname(b"//foo//bar"), b"//foo") + @unittest.expectedFailureIf(os.name == "nt", "TODO: RUSTPYTHON") def test_islink(self): self.assertIs(posixpath.islink(os_helper.TESTFN + "1"), False) self.assertIs(posixpath.lexists(os_helper.TESTFN + "2"), False) @@ -175,10 +176,6 @@ def test_islink(self): self.assertIs(posixpath.islink(os_helper.TESTFN + "\x00"), False) self.assertIs(posixpath.islink(os.fsencode(os_helper.TESTFN) + b"\x00"), False) - # TODO: RUSTPYTHON - if os.name == "nt": - test_islink = unittest.expectedFailure(test_islink) - def test_ismount(self): self.assertIs(posixpath.ismount("/"), True) self.assertIs(posixpath.ismount(b"/"), True) @@ -197,6 +194,7 @@ def test_ismount_non_existent(self): self.assertIs(posixpath.ismount('/\x00'), False) self.assertIs(posixpath.ismount(b'/\x00'), False) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") @unittest.skipUnless(os_helper.can_symlink(), "Test requires symlink support") def test_ismount_symlinks(self): @@ -207,10 +205,6 @@ def test_ismount_symlinks(self): finally: os.unlink(ABSTFN) - # TODO: RUSTPYTHON - if os.name == "nt": - test_ismount_symlinks = unittest.expectedFailure(test_ismount_symlinks) - @unittest.skipIf(posix is None, "Test requires posix module") def test_ismount_different_device(self): # Simulate the path being on a different device from its parent by diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index 6aed9ec7b5..750afc1de7 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -78,6 +78,7 @@ def test_absolute_path(self): self.assertTrue(os.path.exists(self.pyc_path)) self.assertFalse(os.path.exists(self.cache_path)) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_do_not_overwrite_symlinks(self): # In the face of a cfile argument being a symlink, bail out. # Issue #17222 @@ -90,10 +91,6 @@ def test_do_not_overwrite_symlinks(self): with self.assertRaises(FileExistsError): py_compile.compile(self.source_path, self.pyc_path) - # TODO: RUSTPYTHON - if sys.platform == 'win32': - test_do_not_overwrite_symlinks = unittest.expectedFailure(test_do_not_overwrite_symlinks) - @unittest.skipIf(not os.path.exists(os.devnull) or os.path.isfile(os.devnull), 'requires os.devnull and for it to be a non-regular file') def test_do_not_overwrite_nonregular_files(self): @@ -113,17 +110,14 @@ def test_cwd(self): self.assertTrue(os.path.exists(self.pyc_path)) self.assertFalse(os.path.exists(self.cache_path)) + import platform + @unittest.expectedFailureIf(sys.platform == "darwin" and int(platform.release().split(".")[0]) < 20, "TODO: RUSTPYTHON") def test_relative_path(self): py_compile.compile(os.path.relpath(self.source_path), os.path.relpath(self.pyc_path)) self.assertTrue(os.path.exists(self.pyc_path)) self.assertFalse(os.path.exists(self.cache_path)) - # TODO: RUSTPYTHON - import platform - if sys.platform == "darwin" and int(platform.release().split(".")[0]) < 20: - test_relative_path = unittest.expectedFailure(test_relative_path) - @unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0, 'non-root user required') @unittest.skipIf(os.name == 'nt', @@ -273,6 +267,7 @@ def test_bad_syntax_with_quiet(self): self.assertEqual(stdout, b'') self.assertEqual(stderr, b'') + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_file_not_exists(self): should_not_exists = os.path.join(os.path.dirname(__file__), 'should_not_exists.py') rc, stdout, stderr = self.pycompilecmd_failure(self.source_path, should_not_exists) @@ -280,10 +275,6 @@ def test_file_not_exists(self): self.assertEqual(stdout, b'') self.assertIn(b'no such file or directory', stderr.lower()) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_file_not_exists = unittest.expectedFailure(test_file_not_exists) - def test_file_not_exists_with_quiet(self): should_not_exists = os.path.join(os.path.dirname(__file__), 'should_not_exists.py') rc, stdout, stderr = self.pycompilecmd_failure('-q', self.source_path, should_not_exists) diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py index 48e25a06bf..2d87370d92 100644 --- a/Lib/test/test_runpy.py +++ b/Lib/test/test_runpy.py @@ -790,9 +790,11 @@ def assertSigInt(self, *args, **kwargs): self.assertTrue(proc.stderr.endswith("\nKeyboardInterrupt\n")) self.assertEqual(proc.returncode, self.EXPECTED_CODE) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_pymain_run_file(self): self.assertSigInt([sys.executable, self.ham]) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_pymain_run_file_runpy_run_module(self): tmp = self.ham.parent run_module = tmp / "run_module.py" @@ -806,6 +808,7 @@ def test_pymain_run_file_runpy_run_module(self): ) self.assertSigInt([sys.executable, run_module], cwd=tmp) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_pymain_run_file_runpy_run_module_as_main(self): tmp = self.ham.parent run_module_as_main = tmp / "run_module_as_main.py" @@ -819,12 +822,14 @@ def test_pymain_run_file_runpy_run_module_as_main(self): ) self.assertSigInt([sys.executable, run_module_as_main], cwd=tmp) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_pymain_run_command_run_module(self): self.assertSigInt( [sys.executable, "-c", "import runpy; runpy.run_module('ham')"], cwd=self.ham.parent, ) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_pymain_run_command(self): self.assertSigInt([sys.executable, "-c", "import ham"], cwd=self.ham.parent) @@ -833,23 +838,11 @@ def test_pymain_run_command(self): def test_pymain_run_stdin(self): self.assertSigInt([sys.executable], input="import ham", cwd=self.ham.parent) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_pymain_run_module(self): ham = self.ham self.assertSigInt([sys.executable, "-m", ham.stem], cwd=ham.parent) - # TODO: RUSTPYTHON - if sys.platform == "win32": - windows_only_failed_tests = [ - test_pymain_run_file, - test_pymain_run_file_runpy_run_module, - test_pymain_run_file_runpy_run_module_as_main, - test_pymain_run_command_run_module, - test_pymain_run_command, - test_pymain_run_module - ] - for t in windows_only_failed_tests: - unittest.expectedFailure(t) - if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_selectors.py b/Lib/test/test_selectors.py index 98f1c561a2..42c5e8879b 100644 --- a/Lib/test/test_selectors.py +++ b/Lib/test/test_selectors.py @@ -128,6 +128,7 @@ def test_unregister_after_fd_close_and_reuse(self): s.unregister(r) s.unregister(w) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_unregister_after_socket_close(self): s = self.SELECTOR() self.addCleanup(s.close) @@ -139,10 +140,6 @@ def test_unregister_after_socket_close(self): s.unregister(rd) s.unregister(wr) - # TODO: RUSTPYTHON - if sys.platform == 'win32': - test_unregister_after_socket_close = unittest.expectedFailure(test_unregister_after_socket_close) - def test_modify(self): s = self.SELECTOR() self.addCleanup(s.close) diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py index f8122f061a..e59f609121 100644 --- a/Lib/test/test_signal.py +++ b/Lib/test/test_signal.py @@ -178,15 +178,13 @@ def test_invalid_call(self): with self.assertRaises(TypeError): signal.set_wakeup_fd(signal.SIGINT, False) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_invalid_fd(self): fd = os_helper.make_bad_fd() self.assertRaises((ValueError, OSError), signal.set_wakeup_fd, fd) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_invalid_fd = unittest.expectedFailure(test_invalid_fd) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_invalid_socket(self): sock = socket.socket() fd = sock.fileno() @@ -194,10 +192,7 @@ def test_invalid_socket(self): self.assertRaises((ValueError, OSError), signal.set_wakeup_fd, fd) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_invalid_socket = unittest.expectedFailure(test_invalid_socket) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_set_wakeup_fd_result(self): r1, w1 = os.pipe() self.addCleanup(os.close, r1) @@ -215,10 +210,7 @@ def test_set_wakeup_fd_result(self): self.assertEqual(signal.set_wakeup_fd(-1), w2) self.assertEqual(signal.set_wakeup_fd(-1), -1) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_set_wakeup_fd_result = unittest.expectedFailure(test_set_wakeup_fd_result) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_set_wakeup_fd_socket_result(self): sock1 = socket.socket() self.addCleanup(sock1.close) @@ -235,10 +227,6 @@ def test_set_wakeup_fd_socket_result(self): self.assertEqual(signal.set_wakeup_fd(-1), fd2) self.assertEqual(signal.set_wakeup_fd(-1), -1) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_set_wakeup_fd_socket_result = unittest.expectedFailure(test_set_wakeup_fd_socket_result) - # On Windows, files are always blocking and Windows does not provide a # function to test if a socket is in non-blocking mode. @unittest.skipIf(sys.platform == "win32", "tests specific to POSIX") diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index d6cba6b8b3..3c1e013899 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -1576,6 +1576,7 @@ def test_getnameinfo(self): # only IP addresses are allowed self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0) + @unittest.expectedFailureIf(sys.platform != "darwin", "TODO: RUSTPYTHON; socket.gethostbyname_ex") @unittest.skipUnless(support.is_resource_enabled('network'), 'network is not enabled') def test_idna(self): @@ -1593,10 +1594,6 @@ def test_idna(self): # have a reverse entry yet # socket.gethostbyaddr('испытание.python.org') - # TODO: RUSTPYTHON, socket.gethostbyname_ex - if sys.platform != "darwin": - test_idna = unittest.expectedFailure(test_idna) - def check_sendall_interrupted(self, with_timeout): # socketpair() is not strictly required, but it makes things easier. if not hasattr(signal, 'alarm') or not hasattr(socket, 'socketpair'): @@ -1811,6 +1808,7 @@ def test_str_for_enums(self): self.assertEqual(str(s.family), 'AddressFamily.AF_INET') self.assertEqual(str(s.type), 'SocketKind.SOCK_STREAM') + @unittest.expectedFailureIf(sys.platform.startswith("linux"), "TODO: RUSTPYTHON, AssertionError: 526337 != ") def test_socket_consistent_sock_type(self): SOCK_NONBLOCK = getattr(socket, 'SOCK_NONBLOCK', 0) SOCK_CLOEXEC = getattr(socket, 'SOCK_CLOEXEC', 0) @@ -1827,10 +1825,6 @@ def test_socket_consistent_sock_type(self): s.setblocking(False) self.assertEqual(s.type, socket.SOCK_STREAM) - # TODO: RUSTPYTHON, AssertionError: 526337 != - if sys.platform == "linux": - test_socket_consistent_sock_type = unittest.expectedFailure(test_socket_consistent_sock_type) - def test_unknown_socket_family_repr(self): # Test that when created with a family that's not one of the known # AF_*/SOCK_* constants, socket.family just returns the number. diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 92b0ad71c6..4e01c5bf58 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -178,24 +178,18 @@ def dgram_examine(self, proto, addr): buf += data self.assertEqual(buf, TEST_STR) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: -1 != 18446744073709551615") def test_TCPServer(self): self.run_server(socketserver.TCPServer, socketserver.StreamRequestHandler, self.stream_examine) - # TODO: RUSTPYTHON, AssertionError: -1 != 18446744073709551615 - if os.name == "nt": - test_TCPServer = unittest.expectedFailure(test_TCPServer) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: -1 != 18446744073709551615") def test_ThreadingTCPServer(self): self.run_server(socketserver.ThreadingTCPServer, socketserver.StreamRequestHandler, self.stream_examine) - # TODO: RUSTPYTHON, AssertionError: -1 != 18446744073709551615 - if os.name == "nt": - test_ThreadingTCPServer = unittest.expectedFailure(test_ThreadingTCPServer) - @requires_forking def test_ForkingTCPServer(self): with simple_subprocess(self): @@ -223,24 +217,18 @@ def test_ForkingUnixStreamServer(self): socketserver.StreamRequestHandler, self.stream_examine) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: -1 != 18446744073709551615") def test_UDPServer(self): self.run_server(socketserver.UDPServer, socketserver.DatagramRequestHandler, self.dgram_examine) - # TODO: RUSTPYTHON, AssertionError: -1 != 18446744073709551615 - if os.name == "nt": - test_UDPServer = unittest.expectedFailure(test_UDPServer) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: -1 != 18446744073709551615") def test_ThreadingUDPServer(self): self.run_server(socketserver.ThreadingUDPServer, socketserver.DatagramRequestHandler, self.dgram_examine) - # TODO: RUSTPYTHON, AssertionError: -1 != 18446744073709551615 - if os.name == "nt": - test_ThreadingUDPServer = unittest.expectedFailure(test_ThreadingUDPServer) - @requires_forking def test_ForkingUDPServer(self): with simple_subprocess(self): @@ -310,16 +298,13 @@ def test_tcpserver_bind_leak(self): socketserver.TCPServer((HOST, -1), socketserver.StreamRequestHandler) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; AssertionError: -1 != 18446744073709551615") def test_context_manager(self): with socketserver.TCPServer((HOST, 0), socketserver.StreamRequestHandler) as server: pass self.assertEqual(-1, server.socket.fileno()) - # TODO: RUSTPYTHON, AssertionError: -1 != 18446744073709551615 - if os.name == "nt": - test_context_manager = unittest.expectedFailure(test_context_manager) - class ErrorHandlerTest(unittest.TestCase): """Test that the servers pass normal exceptions from the handler to diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py index f4c0bd0de9..08ccebb9ed 100644 --- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -185,6 +185,7 @@ class Y1900Tests(unittest.TestCase): a date before 1900 is passed with a format string containing "%y" """ + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_y_before_1900(self): # Issue #13674, #19634 t = (1899, 1, 1, 0, 0, 0, 0, 0, 0) @@ -195,10 +196,6 @@ def test_y_before_1900(self): else: self.assertEqual(time.strftime("%y", t), "99") - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_y_before_1900 = unittest.expectedFailure(test_y_before_1900) - def test_y_1900(self): self.assertEqual( time.strftime("%y", (1900, 1, 1, 0, 0, 0, 0, 0, 0)), "00") diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 73e0ea5472..2d263fa865 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -936,6 +936,7 @@ def test_communicate_returns(self): self.assertEqual(stdout, None) self.assertEqual(stderr, None) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_communicate_pipe_buf(self): # communicate() with writes larger than pipe_buf # This test will probably deadlock rather than fail, if @@ -959,10 +960,6 @@ def test_communicate_pipe_buf(self): (stdout, stderr) = p.communicate(string_to_write) self.assertEqual(stdout, string_to_write) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_communicate_pipe_buf = unittest.expectedFailure(test_communicate_pipe_buf) - def test_writes_before_communicate(self): # stdin.write before communicate() p = subprocess.Popen([sys.executable, "-c", @@ -1020,6 +1017,7 @@ def test_universal_newlines_and_text(self): self.assertEqual(p.stdout.read(), "line4\nline5\nline6\nline7\nline8") + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_universal_newlines_communicate(self): # universal newlines through communicate() p = subprocess.Popen([sys.executable, "-c", @@ -1045,10 +1043,6 @@ def test_universal_newlines_communicate(self): self.assertEqual(stdout, "line2\nline4\nline5\nline6\nline7\nline8") - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_universal_newlines_communicate = unittest.expectedFailure(test_universal_newlines_communicate) - def test_universal_newlines_communicate_stdin(self): # universal newlines through communicate(), with only stdin p = subprocess.Popen([sys.executable, "-c", @@ -1075,6 +1069,7 @@ def test_universal_newlines_communicate_input_none(self): p.communicate() self.assertEqual(p.returncode, 0) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_universal_newlines_communicate_stdin_stdout_stderr(self): # universal newlines through communicate(), with stdin, stdout, stderr p = subprocess.Popen([sys.executable, "-c", @@ -1103,10 +1098,6 @@ def test_universal_newlines_communicate_stdin_stdout_stderr(self): # to stderr at exit of subprocess. self.assertTrue(stderr.startswith("eline2\neline6\neline7\n")) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_universal_newlines_communicate_stdin_stdout_stderr = unittest.expectedFailure(test_universal_newlines_communicate_stdin_stdout_stderr) - # TODO: RUSTPYTHON @unittest.expectedFailure def test_universal_newlines_communicate_encodings(self): @@ -1272,16 +1263,13 @@ def _test_bufsize_equal_one(self, line, expected, universal_newlines): self.assertEqual(p.returncode, 0) self.assertEqual(read_line, expected) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_bufsize_equal_one_text_mode(self): # line is flushed in text mode with bufsize=1. # we should get the full line in return line = "line\n" self._test_bufsize_equal_one(line, line, universal_newlines=True) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_bufsize_equal_one_text_mode = unittest.expectedFailure(test_bufsize_equal_one_text_mode) - # TODO: RUSTPYTHON @unittest.expectedFailure def test_bufsize_equal_one_binary_mode(self): @@ -1456,6 +1444,7 @@ def test_handles_closed_on_exception(self): self.assertFalse(os.path.exists(ofname)) self.assertFalse(os.path.exists(efname)) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_communicate_epipe(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen(ZERO_RETURN_CMD, @@ -1467,10 +1456,6 @@ def test_communicate_epipe(self): self.addCleanup(p.stdin.close) p.communicate(b"x" * 2**20) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_communicate_epipe = unittest.expectedFailure(test_communicate_epipe) - def test_repr(self): path_cmd = pathlib.Path("my-tool.py") pathlib_cls = path_cmd.__class__.__name__ @@ -1490,6 +1475,7 @@ def test_repr(self): p.returncode = code self.assertEqual(repr(p), sx) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_communicate_epipe_only_stdin(self): # Issue 10963: communicate() should hide EPIPE p = subprocess.Popen(ZERO_RETURN_CMD, @@ -1498,10 +1484,6 @@ def test_communicate_epipe_only_stdin(self): p.wait() p.communicate(b"x" * 2**20) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_communicate_epipe_only_stdin = unittest.expectedFailure(test_communicate_epipe_only_stdin) - # TODO: RUSTPYTHON @unittest.expectedFailure @unittest.skipUnless(hasattr(signal, 'SIGUSR1'), @@ -3674,6 +3656,7 @@ def popen_via_context_manager(*args, **kwargs): raise KeyboardInterrupt # Test how __exit__ handles ^C. self._test_keyboardinterrupt_no_kill(popen_via_context_manager) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_getoutput(self): self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy') self.assertEqual(subprocess.getstatusoutput('echo xyzzy'), @@ -3707,10 +3690,6 @@ def test__all__(self): possible_exports.add(name) self.assertEqual(exported, possible_exports - intentionally_excluded) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_getoutput = unittest.expectedFailure(test_getoutput) - @unittest.skipUnless(hasattr(selectors, 'PollSelector'), "Test needs selectors.PollSelector") diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py index eccf14bd17..90af9da8f9 100644 --- a/Lib/test/test_sundry.py +++ b/Lib/test/test_sundry.py @@ -8,6 +8,7 @@ import unittest class TestUntestedModules(unittest.TestCase): + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_untested_modules_can_be_imported(self): untested = ('encodings',) with warnings_helper.check_warnings(quiet=True): @@ -53,9 +54,5 @@ def test_untested_modules_can_be_imported(self): if support.verbose: print("skipping tty") - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_untested_modules_can_be_imported = unittest.expectedFailure(test_untested_modules_can_be_imported) - if __name__ == "__main__": unittest.main() diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py index 18d4155a00..d93eda773d 100644 --- a/Lib/test/test_support.py +++ b/Lib/test/test_support.py @@ -699,17 +699,13 @@ def test_print_warning(self): self.check_print_warning("a\nb", 'Warning -- a\nWarning -- b\n') + @unittest.expectedFailureIf(sys.platform != "win32", "TODO: RUSTPYTHON") def test_has_strftime_extensions(self): if support.is_emscripten or sys.platform == "win32": self.assertFalse(support.has_strftime_extensions) else: self.assertTrue(support.has_strftime_extensions) - # TODO: RUSTPYTHON - if not sys.platform.startswith("win"): - # TODO: RUSTPYTHON - test_has_strftime_extensions = unittest.expectedFailure(test_has_strftime_extensions) - # XXX -follows a list of untested API # make_legacy_pyc # is_resource_enabled diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index a1238bf206..2d662f94ab 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -165,10 +165,7 @@ def test_posix_venv_scheme(self): sysconfig_includedir = sysconfig.get_path('include', scheme='posix_venv') self.assertTrue(sysconfig_includedir.startswith(incpath + os.sep)) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_posix_venv_scheme = unittest.expectedFailure(test_posix_venv_scheme) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_nt_venv_scheme(self): # The following directories were hardcoded in the venv module # before bpo-45413, here we assert the posix_venv scheme does not regress @@ -185,10 +182,6 @@ def test_nt_venv_scheme(self): self.assertEqual(incpath, sysconfig.get_path('include', scheme='nt_venv')) self.assertEqual(libpath, sysconfig.get_path('purelib', scheme='nt_venv')) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_nt_venv_scheme = unittest.expectedFailure(test_nt_venv_scheme) - def test_venv_scheme(self): if sys.platform == 'win32': self.assertEqual( @@ -353,6 +346,7 @@ def test_get_scheme_names(self): wanted.extend(['nt_user', 'osx_framework_user', 'posix_user']) self.assertEqual(get_scheme_names(), tuple(sorted(wanted))) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") @skip_unless_symlink @requires_subprocess() def test_symlink(self): # Issue 7880 @@ -360,10 +354,6 @@ def test_symlink(self): # Issue 7880 cmd = "-c", "import sysconfig; print(sysconfig.get_platform())" self.assertEqual(py.call_real(*cmd), py.call_link(*cmd)) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_symlink = unittest.expectedFailure(test_symlink) - def test_user_similar(self): # Issue #8759: make sure the posix scheme for the users # is similar to the global posix_prefix one @@ -457,6 +447,7 @@ def test_platform_in_subprocess(self): self.assertEqual(status, 0) self.assertEqual(my_platform, test_platform) + @unittest.expectedFailureIf(sys.platform != "win32", "TODO: RUSTPYTHON") @unittest.skipIf(is_wasi, "Incompatible with WASI mapdir and OOT builds") def test_srcdir(self): # See Issues #15322, #15364. @@ -481,10 +472,6 @@ def test_srcdir(self): makefile_dir = os.path.realpath(makefile_dir) self.assertEqual(makefile_dir, srcdir) - # TODO: RUSTPYTHON - if sys.platform != "win32": - test_srcdir = unittest.expectedFailure(test_srcdir) - def test_srcdir_independent_of_cwd(self): # srcdir should be independent of the current working directory # See Issues #15322, #15364. diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index ea701cf96f..3d6e5a5a97 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -626,6 +626,7 @@ def test_extract_hardlink(self): data = f.read() self.assertEqual(sha256sum(data), sha256_regtype) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_extractall(self): # Test if extractall() correctly restores directory permissions # and times (see issue1735). @@ -656,10 +657,7 @@ def format_mtime(mtime): tar.close() os_helper.rmtree(DIR) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_extractall = unittest.expectedFailure(test_extractall) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_extract_directory(self): dirtype = "ustar/dirtype" DIR = os.path.join(TEMPDIR, "extractdir") @@ -675,10 +673,7 @@ def test_extract_directory(self): finally: os_helper.rmtree(DIR) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_extract_directory = unittest.expectedFailure(test_extract_directory) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_extractall_pathlike_name(self): DIR = pathlib.Path(TEMPDIR) / "extractall" with os_helper.temp_dir(DIR), \ @@ -689,10 +684,7 @@ def test_extractall_pathlike_name(self): path = DIR / tarinfo.name self.assertEqual(os.path.getmtime(path), tarinfo.mtime) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_extractall_pathlike_name = unittest.expectedFailure(test_extractall_pathlike_name) - + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_extract_pathlike_name(self): dirtype = "ustar/dirtype" DIR = pathlib.Path(TEMPDIR) / "extractall" @@ -703,10 +695,6 @@ def test_extract_pathlike_name(self): extracted = DIR / dirtype self.assertEqual(os.path.getmtime(extracted), tarinfo.mtime) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_extract_pathlike_name = unittest.expectedFailure(test_extract_pathlike_name) - def test_init_close_fobj(self): # Issue #7341: Close the internal file object in the TarFile # constructor in case of an error. For the test we rely on @@ -1070,34 +1058,22 @@ def _test_sparse_file(self, name): s = os.stat(filename) self.assertLess(s.st_blocks * 512, s.st_size) + @unittest.expectedFailureIf(sys.platform == "linux", "TODO: RUSTPYTHON") def test_sparse_file_old(self): self._test_sparse_file("gnu/sparse") - # TODO: RUSTPYTHON - if sys.platform == "linux": - test_sparse_file_old = unittest.expectedFailure(test_sparse_file_old) - + @unittest.expectedFailureIf(sys.platform == "linux", "TODO: RUSTPYTHON") def test_sparse_file_00(self): self._test_sparse_file("gnu/sparse-0.0") - # TODO: RUSTPYTHON - if sys.platform == "linux": - test_sparse_file_00 = unittest.expectedFailure(test_sparse_file_00) - + @unittest.expectedFailureIf(sys.platform == "linux", "TODO: RUSTPYTHON") def test_sparse_file_01(self): self._test_sparse_file("gnu/sparse-0.1") - # TODO: RUSTPYTHON - if sys.platform == "linux": - test_sparse_file_01 = unittest.expectedFailure(test_sparse_file_01) - + @unittest.expectedFailureIf(sys.platform == "linux", "TODO: RUSTPYTHON") def test_sparse_file_10(self): self._test_sparse_file("gnu/sparse-1.0") - # TODO: RUSTPYTHON - if sys.platform == "linux": - test_sparse_file_10 = unittest.expectedFailure(test_sparse_file_10) - @staticmethod def _fs_supports_holes(): # Return True if the platform knows the st_blocks stat attribute and @@ -1298,6 +1274,7 @@ def test_gettarinfo_pathlike_name(self): self.assertEqual(tarinfo.name, tarinfo2.name) self.assertEqual(tarinfo.size, 3) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") @unittest.skipUnless(hasattr(os, "link"), "Missing hardlink implementation") def test_link_size(self): @@ -1322,10 +1299,6 @@ def test_link_size(self): os_helper.unlink(target) os_helper.unlink(link) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_link_size = unittest.expectedFailure(test_link_size) - @os_helper.skip_unless_symlink def test_symlink_size(self): path = os.path.join(TEMPDIR, "symlink") @@ -1880,15 +1853,12 @@ def test_add_twice(self): self.assertEqual(tarinfo.type, tarfile.REGTYPE, "add file as regular failed") + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_add_hardlink(self): tarinfo = self.tar.gettarinfo(self.bar) self.assertEqual(tarinfo.type, tarfile.LNKTYPE, "add file as hardlink failed") - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_add_hardlink = unittest.expectedFailure(test_add_hardlink) - def test_dereference_hardlink(self): self.tar.dereference = True tarinfo = self.tar.gettarinfo(self.bar) diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py index 4c4e6fc53f..a2d06d323a 100644 --- a/Lib/test/test_tempfile.py +++ b/Lib/test/test_tempfile.py @@ -1417,6 +1417,7 @@ def do_create2(self, path, recurse=1, dirs=1, files=1): with open(os.path.join(path, "test%d.txt" % i), "wb") as f: f.write(b"Hello world!") + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_mkdtemp_failure(self): # Check no additional exception if mkdtemp fails # Previously would raise AttributeError instead @@ -1427,10 +1428,6 @@ def test_mkdtemp_failure(self): tempfile.TemporaryDirectory(dir=nonexistent) self.assertEqual(cm.exception.errno, errno.ENOENT) - # TODO: RUSTPYTHON - if sys.platform == "win32": - test_mkdtemp_failure = unittest.expectedFailure(test_mkdtemp_failure) - def test_explicit_cleanup(self): # A TemporaryDirectory is deleted when cleaned up dir = tempfile.mkdtemp() diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index 29c0ad92c6..e2d2f89454 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -1237,6 +1237,7 @@ def test_utf8_normalization(self): found, consumed_lines = detect_encoding(rl) self.assertEqual(found, "utf-8") + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_short_files(self): readline = self.get_readline((b'print(something)\n',)) encoding, consumed_lines = detect_encoding(readline) @@ -1260,11 +1261,6 @@ def test_short_files(self): readline = self.get_readline((b'# coding: bad\n',)) self.assertRaises(SyntaxError, detect_encoding, readline) - # TODO: RUSTPYTHON - import sys - if sys.platform == "win32": - test_short_files = unittest.expectedFailure(test_short_files) - def test_false_encoding(self): # Issue 18873: "Encoding" detected in non-comment lines readline = self.get_readline((b'print("#coding=fake")',)) @@ -1320,6 +1316,7 @@ def readline(self): ins = Bunk(lines, path) detect_encoding(ins.readline) + @unittest.expectedFailureIfWindows("TODO: RUSTPYTHON") def test_open_error(self): # Issue #23840: open() must close the binary file on error m = BytesIO(b'#coding:xxx') @@ -1327,11 +1324,6 @@ def test_open_error(self): self.assertRaises(SyntaxError, tokenize_open, 'foobar') self.assertTrue(m.closed) - # TODO: RUSTPYTHON - import sys - if sys.platform == "win32": - test_open_error = unittest.expectedFailure(test_open_error) - class TestTokenize(TestCase): diff --git a/Lib/test/test_utf8_mode.py b/Lib/test/test_utf8_mode.py index 014f133224..b3e3e0bb27 100644 --- a/Lib/test/test_utf8_mode.py +++ b/Lib/test/test_utf8_mode.py @@ -102,6 +102,7 @@ def test_env_var(self): self.assertIn('invalid PYTHONUTF8 environment variable value', out.rstrip()) + @unittest.expectedFailureIf(MS_WINDOWS, "TODO: RUSTPYTHON") def test_filesystemencoding(self): code = textwrap.dedent(''' import sys @@ -125,10 +126,6 @@ def test_filesystemencoding(self): PYTHONLEGACYWINDOWSFSENCODING='1') self.assertEqual(out, 'mbcs/replace') - # TODO: RUSTPYTHON - if MS_WINDOWS: - test_filesystemencoding = unittest.expectedFailure(test_filesystemencoding) - # TODO: RUSTPYTHON @unittest.expectedFailure def test_stdio(self): @@ -220,6 +217,7 @@ def test_locale_getpreferredencoding(self): out = self.get_output('-X', 'utf8', '-c', code, LC_ALL=loc) self.assertEqual(out, 'utf-8 utf-8') + @unittest.expectedFailureIf(sys.platform.startswith("linux"), "TODO: RUSTPYTHON") @unittest.skipIf(MS_WINDOWS, 'test specific to Unix') def test_cmd_line(self): arg = 'h\xe9\u20ac'.encode('utf-8') @@ -247,10 +245,6 @@ def check(utf8_opt, expected, **kw): with self.subTest(LC_ALL=loc): check('utf8=0', [c_arg], LC_ALL=loc) - # TODO: RUSTPYTHON - if sys.platform == "linux": - test_cmd_line = unittest.expectedFailure(test_cmd_line) - def test_optim_level(self): # CPython: check that Py_Main() doesn't increment Py_OptimizeFlag # twice when -X utf8 requires to parse the configuration twice (when