Skip to content

Commit 49cfcd8

Browse files
authored
remove some skipIf and enable shutil CI for windows (RustPython#5235)
* mark failing shtuil tests in windows * unsetenv raise more informed error * Remove a few skipIf for windows
1 parent 39822d7 commit 49cfcd8

File tree

8 files changed

+43
-8
lines changed

8 files changed

+43
-8
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ env:
2424
test_os
2525
test_pathlib
2626
test_posixpath
27-
test_shutil
2827
test_venv
2928
# configparser: https://github.com/RustPython/RustPython/issues/4995#issuecomment-1582397417
3029
# socketserver: seems related to configparser crash.

Lib/test/test_builtin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ def test_open_default_encoding(self):
13631363
os.environ.clear()
13641364
os.environ.update(old_environ)
13651365

1366-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
1366+
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON Windows')
13671367
@support.requires_subprocess()
13681368
def test_open_non_inheritable(self):
13691369
fileobj = open(__file__, encoding="utf-8")

Lib/test/test_regrtest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,15 +945,15 @@ def test_leak(self):
945945
""")
946946
self.check_leak(code, 'file descriptors')
947947

948-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
948+
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON Windows')
949949
def test_list_tests(self):
950950
# test --list-tests
951951
tests = [self.create_test() for i in range(5)]
952952
output = self.run_tests('--list-tests', *tests)
953953
self.assertEqual(output.rstrip().splitlines(),
954954
tests)
955955

956-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
956+
@unittest.expectedFailureIfWindows('TODO: RUSTPYTHON Windows')
957957
def test_list_cases(self):
958958
# test --list-cases
959959
code = textwrap.dedent("""

Lib/test/test_shutil.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ def test_rmtree_works_on_bytes(self):
196196
self.assertIsInstance(victim, bytes)
197197
shutil.rmtree(victim)
198198

199+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
199200
@os_helper.skip_unless_symlink
200201
def test_rmtree_fails_on_symlink_onerror(self):
201202
tmp = self.mkdtemp()
@@ -215,6 +216,7 @@ def onerror(*args):
215216
self.assertEqual(errors[0][1], link)
216217
self.assertIsInstance(errors[0][2][1], OSError)
217218

219+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
218220
@os_helper.skip_unless_symlink
219221
def test_rmtree_fails_on_symlink_onexc(self):
220222
tmp = self.mkdtemp()
@@ -234,6 +236,7 @@ def onexc(*args):
234236
self.assertEqual(errors[0][1], link)
235237
self.assertIsInstance(errors[0][2], OSError)
236238

239+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
237240
@os_helper.skip_unless_symlink
238241
def test_rmtree_works_on_symlinks(self):
239242
tmp = self.mkdtemp()
@@ -256,6 +259,7 @@ def test_rmtree_works_on_symlinks(self):
256259
self.assertTrue(os.path.exists(dir3))
257260
self.assertTrue(os.path.exists(file1))
258261

262+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
259263
@unittest.skipUnless(_winapi, 'only relevant on Windows')
260264
def test_rmtree_fails_on_junctions_onerror(self):
261265
tmp = self.mkdtemp()
@@ -276,6 +280,7 @@ def onerror(*args):
276280
self.assertEqual(errors[0][1], link)
277281
self.assertIsInstance(errors[0][2][1], OSError)
278282

283+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
279284
@unittest.skipUnless(_winapi, 'only relevant on Windows')
280285
def test_rmtree_fails_on_junctions_onexc(self):
281286
tmp = self.mkdtemp()
@@ -296,6 +301,7 @@ def onexc(*args):
296301
self.assertEqual(errors[0][1], link)
297302
self.assertIsInstance(errors[0][2], OSError)
298303

304+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
299305
@unittest.skipUnless(_winapi, 'only relevant on Windows')
300306
def test_rmtree_works_on_junctions(self):
301307
tmp = self.mkdtemp()
@@ -655,6 +661,7 @@ def test_rmtree_on_symlink(self):
655661
finally:
656662
shutil.rmtree(TESTFN, ignore_errors=True)
657663

664+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
658665
@unittest.skipUnless(_winapi, 'only relevant on Windows')
659666
def test_rmtree_on_junction(self):
660667
os.mkdir(TESTFN)
@@ -708,6 +715,7 @@ def test_copytree_simple(self):
708715
actual = read_file((dst_dir, 'test_dir', 'test.txt'))
709716
self.assertEqual(actual, '456')
710717

718+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
711719
def test_copytree_dirs_exist_ok(self):
712720
src_dir = self.mkdtemp()
713721
dst_dir = self.mkdtemp()
@@ -733,6 +741,7 @@ def test_copytree_dirs_exist_ok(self):
733741
with self.assertRaises(FileExistsError):
734742
shutil.copytree(src_dir, dst_dir, dirs_exist_ok=False)
735743

744+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
736745
@os_helper.skip_unless_symlink
737746
def test_copytree_symlinks(self):
738747
tmp_dir = self.mkdtemp()
@@ -972,6 +981,7 @@ def _copy(src, dst):
972981
shutil.copytree(src_dir, dst_dir, copy_function=_copy)
973982
self.assertEqual(len(copied), 2)
974983

984+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
975985
@os_helper.skip_unless_symlink
976986
def test_copytree_dangling_symlinks(self):
977987
src_dir = self.mkdtemp()
@@ -999,6 +1009,7 @@ def test_copytree_dangling_symlinks(self):
9991009
shutil.copytree(src_dir, dst_dir, symlinks=True)
10001010
self.assertIn('test.txt', os.listdir(dst_dir))
10011011

1012+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
10021013
@os_helper.skip_unless_symlink
10031014
def test_copytree_symlink_dir(self):
10041015
src_dir = self.mkdtemp()
@@ -1045,6 +1056,7 @@ class TestCopy(BaseTest, unittest.TestCase):
10451056

10461057
### shutil.copymode
10471058

1059+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
10481060
@os_helper.skip_unless_symlink
10491061
def test_copymode_follow_symlinks(self):
10501062
tmp_dir = self.mkdtemp()
@@ -1126,6 +1138,7 @@ def test_copymode_symlink_to_symlink_wo_lchmod(self):
11261138

11271139
### shutil.copystat
11281140

1141+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
11291142
@os_helper.skip_unless_symlink
11301143
def test_copystat_symlinks(self):
11311144
tmp_dir = self.mkdtemp()
@@ -1306,6 +1319,7 @@ def test_copy(self):
13061319
self.assertTrue(os.path.exists(file2))
13071320
self.assertEqual(os.stat(file1).st_mode, os.stat(file2).st_mode)
13081321

1322+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
13091323
@os_helper.skip_unless_symlink
13101324
def test_copy_symlinks(self):
13111325
tmp_dir = self.mkdtemp()
@@ -1348,6 +1362,7 @@ def test_copy2(self):
13481362
self.assertEqual(getattr(file1_stat, 'st_flags'),
13491363
getattr(file2_stat, 'st_flags'))
13501364

1365+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
13511366
@os_helper.skip_unless_symlink
13521367
def test_copy2_symlinks(self):
13531368
tmp_dir = self.mkdtemp()
@@ -1432,6 +1447,7 @@ def _test_copy_dir(self, copy_func):
14321447

14331448
### shutil.copyfile
14341449

1450+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
14351451
@os_helper.skip_unless_symlink
14361452
def test_copyfile_symlinks(self):
14371453
tmp_dir = self.mkdtemp()
@@ -1542,6 +1558,7 @@ def test_copyfile_nonexistent_dir(self):
15421558
write_file(src_file, 'foo')
15431559
self.assertRaises(FileNotFoundError, shutil.copyfile, src_file, dst)
15441560

1561+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
15451562
def test_copyfile_copy_dir(self):
15461563
# Issue 45234
15471564
# test copy() and copyfile() raising proper exceptions when src and/or
@@ -2482,15 +2499,18 @@ def test_move_file(self):
24822499
# Move a file to another location on the same filesystem.
24832500
self._check_move_file(self.src_file, self.dst_file, self.dst_file)
24842501

2502+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
24852503
def test_move_file_to_dir(self):
24862504
# Move a file inside an existing dir on the same filesystem.
24872505
self._check_move_file(self.src_file, self.dst_dir, self.dst_file)
24882506

2507+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
24892508
def test_move_file_to_dir_pathlike_src(self):
24902509
# Move a pathlike file to another location on the same filesystem.
24912510
src = pathlib.Path(self.src_file)
24922511
self._check_move_file(src, self.dst_dir, self.dst_file)
24932512

2513+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
24942514
def test_move_file_to_dir_pathlike_dst(self):
24952515
# Move a file to another pathlike location on the same filesystem.
24962516
dst = pathlib.Path(self.dst_dir)
@@ -2501,6 +2521,7 @@ def test_move_file_other_fs(self):
25012521
# Move a file to an existing dir on another filesystem.
25022522
self.test_move_file()
25032523

2524+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25042525
@mock_rename
25052526
def test_move_file_to_dir_other_fs(self):
25062527
# Move a file to another location on another filesystem.
@@ -2519,25 +2540,30 @@ def test_move_dir_other_fs(self):
25192540
# Move a dir to another location on another filesystem.
25202541
self.test_move_dir()
25212542

2543+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25222544
def test_move_dir_to_dir(self):
25232545
# Move a dir inside an existing dir on the same filesystem.
25242546
self._check_move_dir(self.src_dir, self.dst_dir,
25252547
os.path.join(self.dst_dir, os.path.basename(self.src_dir)))
25262548

2549+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25272550
@mock_rename
25282551
def test_move_dir_to_dir_other_fs(self):
25292552
# Move a dir inside an existing dir on another filesystem.
25302553
self.test_move_dir_to_dir()
25312554

2555+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25322556
def test_move_dir_sep_to_dir(self):
25332557
self._check_move_dir(self.src_dir + os.path.sep, self.dst_dir,
25342558
os.path.join(self.dst_dir, os.path.basename(self.src_dir)))
25352559

2560+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25362561
@unittest.skipUnless(os.path.altsep, 'requires os.path.altsep')
25372562
def test_move_dir_altsep_to_dir(self):
25382563
self._check_move_dir(self.src_dir + os.path.altsep, self.dst_dir,
25392564
os.path.join(self.dst_dir, os.path.basename(self.src_dir)))
25402565

2566+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25412567
def test_existing_file_inside_dest_dir(self):
25422568
# A file with the same name inside the destination dir already exists.
25432569
with open(self.dst_file, "wb"):
@@ -2573,6 +2599,7 @@ def test_destinsrc_false_positive(self):
25732599
finally:
25742600
os_helper.rmtree(TESTFN)
25752601

2602+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25762603
@os_helper.skip_unless_symlink
25772604
@mock_rename
25782605
def test_move_file_symlink(self):
@@ -2582,6 +2609,7 @@ def test_move_file_symlink(self):
25822609
self.assertTrue(os.path.islink(self.dst_file))
25832610
self.assertTrue(os.path.samefile(self.src_file, self.dst_file))
25842611

2612+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25852613
@os_helper.skip_unless_symlink
25862614
@mock_rename
25872615
def test_move_file_symlink_to_dir(self):
@@ -2593,6 +2621,7 @@ def test_move_file_symlink_to_dir(self):
25932621
self.assertTrue(os.path.islink(final_link))
25942622
self.assertTrue(os.path.samefile(self.src_file, final_link))
25952623

2624+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
25962625
@os_helper.skip_unless_symlink
25972626
@mock_rename
25982627
def test_move_dangling_symlink(self):
@@ -2604,6 +2633,7 @@ def test_move_dangling_symlink(self):
26042633
self.assertTrue(os.path.islink(dst_link))
26052634
self.assertEqual(os.path.realpath(src), os.path.realpath(dst_link))
26062635

2636+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26072637
@os_helper.skip_unless_symlink
26082638
@mock_rename
26092639
def test_move_dir_symlink(self):
@@ -2616,6 +2646,7 @@ def test_move_dir_symlink(self):
26162646
self.assertTrue(os.path.islink(dst_link))
26172647
self.assertTrue(os.path.samefile(src, dst_link))
26182648

2649+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26192650
def test_move_return_value(self):
26202651
rv = shutil.move(self.src_file, self.dst_dir)
26212652
self.assertEqual(rv,
@@ -2625,6 +2656,7 @@ def test_move_as_rename_return_value(self):
26252656
rv = shutil.move(self.src_file, os.path.join(self.dst_dir, 'bar'))
26262657
self.assertEqual(rv, os.path.join(self.dst_dir, 'bar'))
26272658

2659+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26282660
@mock_rename
26292661
def test_move_file_special_function(self):
26302662
moved = []
@@ -2633,6 +2665,7 @@ def _copy(src, dst):
26332665
shutil.move(self.src_file, self.dst_dir, copy_function=_copy)
26342666
self.assertEqual(len(moved), 1)
26352667

2668+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26362669
@mock_rename
26372670
def test_move_dir_special_function(self):
26382671
moved = []
@@ -2661,6 +2694,7 @@ def test_move_dir_caseinsensitive(self):
26612694

26622695
# bpo-26791: Check that a symlink to a directory can
26632696
# be moved into that directory.
2697+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26642698
@mock_rename
26652699
def _test_move_symlink_to_dir_into_dir(self, dst):
26662700
src = os.path.join(self.src_dir, 'linktodir')
@@ -2679,10 +2713,12 @@ def _test_move_symlink_to_dir_into_dir(self, dst):
26792713
self.assertTrue(os.path.samefile(self.dst_dir, dst_link))
26802714
self.assertTrue(os.path.exists(src))
26812715

2716+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26822717
@os_helper.skip_unless_symlink
26832718
def test_move_symlink_to_dir_into_dir(self):
26842719
self._test_move_symlink_to_dir_into_dir(self.dst_dir)
26852720

2721+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
26862722
@os_helper.skip_unless_symlink
26872723
def test_move_symlink_to_dir_into_symlink_to_dir(self):
26882724
dst = os.path.join(self.src_dir, 'otherlinktodir')
@@ -2859,6 +2895,7 @@ def test_file_offset(self):
28592895
self.assertEqual(src.tell(), self.FILESIZE)
28602896
self.assertEqual(dst.tell(), self.FILESIZE)
28612897

2898+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON")
28622899
@unittest.skipIf(os.name != 'nt', "Windows only")
28632900
def test_win_impl(self):
28642901
# Make sure alternate Windows implementation is called.

Lib/test/test_subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def is_env_var_to_ignore(n):
811811
if not is_env_var_to_ignore(k)]
812812
self.assertEqual(child_env_names, [])
813813

814-
@unittest.skipIf(sys.platform == "win32", "TODO: RUSTPYTHON, null byte is not checked")
814+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON, null byte is not checked")
815815
def test_invalid_cmd(self):
816816
# null character in the command name
817817
cmd = sys.executable + '\0'

Lib/test/test_support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def test_temp_cwd__name_none(self):
310310
def test_sortdict(self):
311311
self.assertEqual(support.sortdict({3:3, 2:2, 1:1}), "{1: 1, 2: 2, 3: 3}")
312312

313-
@unittest.skipIf(sys.platform.startswith("win"), "TODO: RUSTPYTHON; actual c fds on windows")
313+
@unittest.expectedFailureIfWindows("TODO: RUSTPYTHON; actual c fds on windows")
314314
def test_make_bad_fd(self):
315315
fd = os_helper.make_bad_fd()
316316
with self.assertRaises(OSError) as cm:

Lib/test/test_threadedtempfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def run(self):
5050

5151

5252
class ThreadedTempFileTest(unittest.TestCase):
53-
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
5453
def test_main(self):
5554
threads = [TempFileGreedy() for i in range(NUM_THREADS)]
5655
with threading_helper.start_threads(threads, startEvent.set):

vm/src/stdlib/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pub(super) mod _os {
407407
return Err(vm.new_value_error("embedded null byte".to_string()));
408408
}
409409
if key.is_empty() || key.contains('=') {
410-
return Err(vm.new_errno_error(22, "Invalid argument".to_owned()));
410+
return Err(vm.new_errno_error(22, format!("Invalid argument: {key}")));
411411
}
412412
env::remove_var(key);
413413
Ok(())

0 commit comments

Comments
 (0)