Skip to content
Prev Previous commit
Next Next commit
Apply patches to test_os.py
  • Loading branch information
ShaharNaveh committed Sep 9, 2025
commit efdcfccd2a1a1cc21c5d1cdc8f4e1860aeb81b88
64 changes: 32 additions & 32 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_access(self):
os.close(f)
self.assertTrue(os.access(os_helper.TESTFN, os.W_OK))

@unittest.skipIf(sys.platform == 'win32', "TODO: RUSTPYTHON; , BrokenPipeError: (32, 'The process cannot access the file because it is being used by another process. (os error 32)')")
@unittest.skipIf(sys.platform == 'win32', "TODO: RUSTPYTHON; BrokenPipeError: (32, 'The process cannot access the file because it is being used by another process. (os error 32)')")
@unittest.skipIf(
support.is_emscripten, "Test is unstable under Emscripten."
)
Expand Down Expand Up @@ -714,7 +714,7 @@ def check_file_attributes(self, result):
self.assertTrue(isinstance(result.st_file_attributes, int))
self.assertTrue(0 <= result.st_file_attributes <= 0xFFFFFFFF)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.stat return value doesnt have st_file_attributes attribute")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.stat return value doesnt have st_file_attributes attribute')
@unittest.skipUnless(sys.platform == "win32",
"st_file_attributes is Win32 specific")
def test_file_attributes(self):
Expand All @@ -736,7 +736,7 @@ def test_file_attributes(self):
result.st_file_attributes & stat.FILE_ATTRIBUTE_DIRECTORY,
stat.FILE_ATTRIBUTE_DIRECTORY)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.stat (PermissionError: [Errno 5] Access is denied.)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.stat (PermissionError: [Errno 5] Access is denied.)')
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
def test_access_denied(self):
# Default to FindFirstFile WIN32_FIND_DATA when access is
Expand All @@ -759,7 +759,7 @@ def test_access_denied(self):
self.assertNotEqual(result.st_size, 0)
self.assertTrue(os.path.isfile(fname))

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.stat (PermissionError: [Errno 1] Incorrect function.)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.stat (PermissionError: [Errno 1] Incorrect function.)')
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
def test_stat_block_device(self):
# bpo-38030: os.stat fails for block devices
Expand Down Expand Up @@ -817,7 +817,7 @@ def _test_utime(self, set_time, filename=None):
self.assertEqual(st.st_atime_ns, atime_ns)
self.assertEqual(st.st_mtime_ns, mtime_ns)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (AssertionError: 2.002003 != 1.002003 within 1e-06 delta (1.0000000000000002 difference))")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (AssertionError: 2.002003 != 1.002003 within 1e-06 delta (1.0000000000000002 difference))')
def test_utime(self):
def set_time(filename, ns):
# test the ns keyword parameter
Expand Down Expand Up @@ -883,7 +883,7 @@ def set_time(filename, ns):
os.utime(name, dir_fd=dirfd, ns=ns)
self._test_utime(set_time)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (AssertionError: 2.002003 != 1.002003 within 1e-06 delta (1.0000000000000002 difference))")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (AssertionError: 2.002003 != 1.002003 within 1e-06 delta (1.0000000000000002 difference))')
def test_utime_directory(self):
def set_time(filename, ns):
# test calling os.utime() on a directory
Expand Down Expand Up @@ -912,14 +912,14 @@ def _test_utime_current(self, set_time):
self.assertAlmostEqual(st.st_mtime, current,
delta=delta, msg=msg)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (AssertionError: 3359485824.516508 != 1679742912.516503 within 0.05 delta (1679742912.000005 difference) : st_time=3359485824.516508, current=1679742912.516503, dt=1679742912.000005)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (AssertionError: 3359485824.516508 != 1679742912.516503 within 0.05 delta (1679742912.000005 difference) : st_time=3359485824.516508, current=1679742912.516503, dt=1679742912.000005)')
def test_utime_current(self):
def set_time(filename):
# Set to the current time in the new way
os.utime(self.fname)
self._test_utime_current(set_time)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (AssertionError: 3359485824.5186944 != 1679742912.5186892 within 0.05 delta (1679742912.0000052 difference) : st_time=3359485824.5186944, current=1679742912.5186892, dt=1679742912.0000052)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (AssertionError: 3359485824.5186944 != 1679742912.5186892 within 0.05 delta (1679742912.0000052 difference) : st_time=3359485824.5186944, current=1679742912.5186892, dt=1679742912.0000052)')
def test_utime_current_old(self):
def set_time(filename):
# Set to the current time in the old explicit way.
Expand Down Expand Up @@ -958,7 +958,7 @@ def test_large_time(self):
os.utime(self.fname, (large, large))
self.assertEqual(os.stat(self.fname).st_mtime, large)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (AssertionError: NotImplementedError not raised)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (AssertionError: NotImplementedError not raised)')
def test_utime_invalid_arguments(self):
# seconds and nanoseconds parameters are mutually exclusive
with self.assertRaises(ValueError):
Expand Down Expand Up @@ -1161,7 +1161,7 @@ def test_putenv_unsetenv(self):
self.assertEqual(proc.stdout.rstrip(), repr(None))

# On OS X < 10.6, unsetenv() doesn't return a value (bpo-13415).
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (AssertionError: ValueError not raised by putenv)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (AssertionError: ValueError not raised by putenv)')
@support.requires_mac_ver(10, 6)
def test_putenv_unsetenv_error(self):
# Empty variable name is invalid.
Expand Down Expand Up @@ -1796,7 +1796,7 @@ def test_mode(self):
self.assertEqual(os.stat(path).st_mode & 0o777, 0o555)
self.assertEqual(os.stat(parent).st_mode & 0o777, 0o775)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.umask not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.umask not implemented yet for all platforms')
@unittest.skipIf(
support.is_emscripten or support.is_wasi,
"Emscripten's/WASI's umask is a stub."
Expand All @@ -1815,7 +1815,7 @@ def test_exist_ok_existing_directory(self):
# Issue #25583: A drive root could raise PermissionError on Windows
os.makedirs(os.path.abspath('/'), exist_ok=True)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.umask not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.umask not implemented yet for all platforms')
@unittest.skipIf(
support.is_emscripten or support.is_wasi,
"Emscripten's/WASI's umask is a stub."
Expand Down Expand Up @@ -2205,7 +2205,7 @@ def test_execv_with_bad_arglist(self):
self.assertRaises(ValueError, os.execv, 'notepad', ('',))
self.assertRaises(ValueError, os.execv, 'notepad', [''])

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.execve not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.execve not implemented yet for all platforms')
def test_execvpe_with_bad_arglist(self):
self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
self.assertRaises(ValueError, os.execvpe, 'notepad', [], {})
Expand Down Expand Up @@ -2265,7 +2265,7 @@ def test_internal_execvpe_str(self):
if os.name != "nt":
self._test_internal_execvpe(bytes)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.execve not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.execve not implemented yet for all platforms')
def test_execve_invalid_env(self):
args = [sys.executable, '-c', 'pass']

Expand All @@ -2287,7 +2287,7 @@ def test_execve_invalid_env(self):
with self.assertRaises(ValueError):
os.execve(args[0], args, newenv)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.execve not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.execve not implemented yet for all platforms')
@unittest.skipUnless(sys.platform == "win32", "Win32-specific test")
def test_execve_with_empty_path(self):
# bpo-32890: Check GetLastError() misuse
Expand Down Expand Up @@ -2445,12 +2445,12 @@ def test_ftruncate(self):
self.check(os.ftruncate, 0)
self.check_bool(os.truncate, 0)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (OSError: [Errno 18] There are no more files.)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (OSError: [Errno 18] There are no more files.)')
@unittest.skipUnless(hasattr(os, 'lseek'), 'test needs os.lseek()')
def test_lseek(self):
self.check(os.lseek, 0, 0)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (OSError: [Errno 18] There are no more files.)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (OSError: [Errno 18] There are no more files.)')
@unittest.skipUnless(hasattr(os, 'read'), 'test needs os.read()')
def test_read(self):
self.check(os.read, 1)
Expand All @@ -2464,7 +2464,7 @@ def test_readv(self):
def test_tcsetpgrpt(self):
self.check(os.tcsetpgrp, 0)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (OSError: [Errno 18] There are no more files.)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (OSError: [Errno 18] There are no more files.)')
@unittest.skipUnless(hasattr(os, 'write'), 'test needs os.write()')
def test_write(self):
self.check(os.write, b" ")
Expand All @@ -2473,7 +2473,7 @@ def test_write(self):
def test_writev(self):
self.check(os.writev, [b'abc'])

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms')
@support.requires_subprocess()
def test_inheritable(self):
self.check(os.get_inheritable)
Expand Down Expand Up @@ -3225,7 +3225,7 @@ def test_getfinalpathname_handles(self):

self.assertEqual(0, handle_delta)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.stat (PermissionError: [Errno 5] Access is denied.)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.stat (PermissionError: [Errno 5] Access is denied.)')
@support.requires_subprocess()
def test_stat_unlink_race(self):
# bpo-46785: the implementation of os.stat() falls back to reading
Expand Down Expand Up @@ -3435,7 +3435,7 @@ def test_waitstatus_to_exitcode(self):
with self.assertRaises(TypeError):
os.waitstatus_to_exitcode(0.0)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.spawnv not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.spawnv not implemented yet for all platforms')
@unittest.skipUnless(sys.platform == 'win32', 'win32-specific test')
def test_waitpid_windows(self):
# bpo-40138: test os.waitpid() and os.waitstatus_to_exitcode()
Expand All @@ -3444,7 +3444,7 @@ def test_waitpid_windows(self):
code = f'import _winapi; _winapi.ExitProcess({STATUS_CONTROL_C_EXIT})'
self.check_waitpid(code, exitcode=STATUS_CONTROL_C_EXIT)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (OverflowError: Python int too large to convert to Rust i32)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (OverflowError: Python int too large to convert to Rust i32)')
@unittest.skipUnless(sys.platform == 'win32', 'win32-specific test')
def test_waitstatus_to_exitcode_windows(self):
max_exitcode = 2 ** 32 - 1
Expand Down Expand Up @@ -4621,7 +4621,7 @@ def test_process_cpu_count_affinity(self):
# FD inheritance check is only useful for systems with process support.
@support.requires_subprocess()
class FDInheritanceTests(unittest.TestCase):
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms')
def test_get_set_inheritable(self):
fd = os.open(__file__, os.O_RDONLY)
self.addCleanup(os.close, fd)
Expand Down Expand Up @@ -4666,7 +4666,7 @@ def test_get_set_inheritable_o_path(self):
os.set_inheritable(fd, False)
self.assertEqual(os.get_inheritable(fd), False)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms')
def test_get_set_inheritable_badf(self):
fd = os_helper.make_bad_fd()

Expand All @@ -4682,7 +4682,7 @@ def test_get_set_inheritable_badf(self):
os.set_inheritable(fd, False)
self.assertEqual(ctx.exception.errno, errno.EBADF)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.get_inheritable not implemented yet for all platforms')
def test_open(self):
fd = os.open(__file__, os.O_RDONLY)
self.addCleanup(os.close, fd)
Expand All @@ -4696,7 +4696,7 @@ def test_pipe(self):
self.assertEqual(os.get_inheritable(rfd), False)
self.assertEqual(os.get_inheritable(wfd), False)

@unittest.skipIf(sys.platform == 'win32', "TODO: RUSTPYTHON; os.dup on windows")
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON; os.dup on windows')
def test_dup(self):
fd1 = os.open(__file__, os.O_RDONLY)
self.addCleanup(os.close, fd1)
Expand All @@ -4705,13 +4705,13 @@ def test_dup(self):
self.addCleanup(os.close, fd2)
self.assertEqual(os.get_inheritable(fd2), False)

@unittest.skipIf(sys.platform == 'win32', "TODO: RUSTPYTHON; os.dup on windows")
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON; os.dup on windows')
def test_dup_standard_stream(self):
fd = os.dup(1)
self.addCleanup(os.close, fd)
self.assertGreater(fd, 0)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; os.dup not implemented yet for all platforms")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; os.dup not implemented yet for all platforms')
@unittest.skipUnless(sys.platform == 'win32', 'win32-specific test')
def test_dup_nul(self):
# os.dup() was creating inheritable fds for character files.
Expand Down Expand Up @@ -5028,7 +5028,7 @@ def check_entry(self, entry, name, is_dir, is_file, is_symlink):
entry_lstat,
os.name == 'nt')

@unittest.skipIf(sys.platform == 'linux', "TODO: RUSTPYTHON; , flaky test")
@unittest.skipIf(sys.platform == 'linux', 'TODO: RUSTPYTHON; flaky test')
def test_attributes(self):
link = os_helper.can_hardlink()
symlink = os_helper.can_symlink()
Expand Down Expand Up @@ -5128,7 +5128,7 @@ def test_fspath_protocol_bytes(self):
self.assertEqual(fspath,
os.path.join(os.fsencode(self.path),bytes_filename))

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; entry.is_dir() is False")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; entry.is_dir() is False')
def test_removed_dir(self):
path = os.path.join(self.path, 'dir')

Expand All @@ -5151,7 +5151,7 @@ def test_removed_dir(self):
self.assertRaises(FileNotFoundError, entry.stat)
self.assertRaises(FileNotFoundError, entry.stat, follow_symlinks=False)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; entry.is_file() is False")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; entry.is_file() is False')
def test_removed_file(self):
entry = self.create_file_entry()
os.unlink(entry.path)
Expand Down Expand Up @@ -5239,7 +5239,7 @@ def test_fd(self):
st = os.stat(entry.name, dir_fd=fd, follow_symlinks=False)
self.assertEqual(entry.stat(follow_symlinks=False), st)

@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; (AssertionError: FileNotFoundError not raised by scandir)")
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON; (AssertionError: FileNotFoundError not raised by scandir)')
@unittest.skipIf(support.is_wasi, "WASI maps '' to cwd")
def test_empty_path(self):
self.assertRaises(FileNotFoundError, os.scandir, '')
Expand Down