From a78e272f5018ef1b88cfbee3e6b65dbcf777986b Mon Sep 17 00:00:00 2001 From: ste1hi <1874076121@qq.com> Date: Sun, 18 Oct 2026 00:00:35 +0800 Subject: [PATCH 1/3] complete test in random.sample --- Lib/test/test_random.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index 8d093ab1b7014a4..2bf3cc3955bbf5e 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -154,6 +154,8 @@ def test_sample(self): self.assertRaises(ValueError, self.gen.sample, population, N+1) self.assertRaises(ValueError, self.gen.sample, [], -1) self.assertRaises(TypeError, self.gen.sample, population, 1.0) + with self.assertRaises(TypeError): + self.gen.sample(population, 1, counts = [" "] * N) def test_sample_distribution(self): # For the entire allowable range of 0 <= k <= N, validate that From ebb4a7a62d95fde9283357b0c10e40a0113b4358 Mon Sep 17 00:00:00 2001 From: ste1hi <1874076121@qq.com> Date: Sun, 18 Oct 2026 10:50:26 +0800 Subject: [PATCH 2/3] Add test for os.renames --- Lib/test/test_os/test_os.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Lib/test/test_os/test_os.py b/Lib/test/test_os/test_os.py index 81b3043eb7e75bc..f7b2c7cdfe023d9 100644 --- a/Lib/test/test_os/test_os.py +++ b/Lib/test/test_os/test_os.py @@ -233,6 +233,24 @@ def test_rename(self): new = sys.getrefcount(path) self.assertEqual(old, new) + def test_renames(self): + old_path = os_helper.TESTFN + "old_dir" + old = os.path.join(old_path, "test") + os.mkdir(old_path) + open(old, "w+b").close() + self.addCleanup(os_helper.rmdir, old_path) + self.addCleanup(os_helper.unlink, old) + + new_path = os_helper.TESTFN + "new_dir" + new = os.path.join(new_path, "test") + self.addCleanup(os_helper.rmdir, new_path) + self.addCleanup(os_helper.unlink, new) + + os.renames(old, new) + self.assertTrue(os.path.exists(new)) + self.assertFalse(os.path.exists(old)) + self.assertFalse(os.path.exists(old_path)) + def test_read(self): with open(os_helper.TESTFN, "w+b") as fobj: fobj.write(b"spam") From 9f4eb7632475f776a31c70af4d73f5ad683288bb Mon Sep 17 00:00:00 2001 From: ste1hi <49638961+ste1hi@users.noreply.github.com> Date: Mon, 19 Oct 2026 11:49:16 +0800 Subject: [PATCH 3/3] Remove unnecessary test in sample test --- Lib/test/test_random.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index 2bf3cc3955bbf5e..8d093ab1b7014a4 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -154,8 +154,6 @@ def test_sample(self): self.assertRaises(ValueError, self.gen.sample, population, N+1) self.assertRaises(ValueError, self.gen.sample, [], -1) self.assertRaises(TypeError, self.gen.sample, population, 1.0) - with self.assertRaises(TypeError): - self.gen.sample(population, 1, counts = [" "] * N) def test_sample_distribution(self): # For the entire allowable range of 0 <= k <= N, validate that