Skip to content

Commit af01b46

Browse files
authored
gh-139322: Remove redundant test_os.Win32ErrorTests (#139477)
test_os.OSErrorTests already covers the OSError class and is more complete than Win32ErrorTests.
1 parent 9bf6965 commit af01b46

File tree

2 files changed

+14
-35
lines changed

2 files changed

+14
-35
lines changed

Lib/test/test_os/test_os.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,6 +4080,7 @@ def test_oserror_filename(self):
40804080
(self.filenames, os.listdir,),
40814081
(self.filenames, os.rename, "dst"),
40824082
(self.filenames, os.replace, "dst"),
4083+
(self.filenames, os.utime, None),
40834084
]
40844085
if os_helper.can_chmod():
40854086
funcs.append((self.filenames, os.chmod, 0o777))
@@ -4120,6 +4121,19 @@ def test_oserror_filename(self):
41204121
else:
41214122
self.fail(f"No exception thrown by {func}")
41224123

4124+
def test_mkdir(self):
4125+
filename = os_helper.TESTFN
4126+
subdir = os.path.join(filename, 'subdir')
4127+
self.assertRaises(FileNotFoundError, os.mkdir, subdir)
4128+
4129+
self.addCleanup(os_helper.unlink, filename)
4130+
create_file(filename)
4131+
self.assertRaises(FileExistsError, os.mkdir, filename)
4132+
4133+
self.assertRaises((NotADirectoryError, FileNotFoundError),
4134+
os.mkdir, subdir)
4135+
4136+
41234137
class CPUCountTests(unittest.TestCase):
41244138
def check_cpu_count(self, cpus):
41254139
if cpus is None:

Lib/test/test_os/test_windows.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,41 +21,6 @@
2121
from .utils import create_file
2222

2323

24-
class Win32ErrorTests(unittest.TestCase):
25-
def setUp(self):
26-
try:
27-
os.stat(os_helper.TESTFN)
28-
except FileNotFoundError:
29-
exists = False
30-
except OSError as exc:
31-
exists = True
32-
self.fail("file %s must not exist; os.stat failed with %s"
33-
% (os_helper.TESTFN, exc))
34-
else:
35-
self.fail("file %s must not exist" % os_helper.TESTFN)
36-
37-
def test_rename(self):
38-
self.assertRaises(OSError, os.rename, os_helper.TESTFN, os_helper.TESTFN+".bak")
39-
40-
def test_remove(self):
41-
self.assertRaises(OSError, os.remove, os_helper.TESTFN)
42-
43-
def test_chdir(self):
44-
self.assertRaises(OSError, os.chdir, os_helper.TESTFN)
45-
46-
def test_mkdir(self):
47-
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
48-
49-
with open(os_helper.TESTFN, "x") as f:
50-
self.assertRaises(OSError, os.mkdir, os_helper.TESTFN)
51-
52-
def test_utime(self):
53-
self.assertRaises(OSError, os.utime, os_helper.TESTFN, None)
54-
55-
def test_chmod(self):
56-
self.assertRaises(OSError, os.chmod, os_helper.TESTFN, 0)
57-
58-
5924
class Win32KillTests(unittest.TestCase):
6025
def _kill(self, sig):
6126
# Start sys.executable as a subprocess and communicate from the

0 commit comments

Comments
 (0)