mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-139322: Remove redundant test_os.Win32ErrorTests (#139477)
test_os.OSErrorTests already covers the OSError class and is more complete than Win32ErrorTests.
This commit is contained in:
parent
9bf69659e1
commit
af01b46866
2 changed files with 14 additions and 35 deletions
|
|
@ -4080,6 +4080,7 @@ def test_oserror_filename(self):
|
||||||
(self.filenames, os.listdir,),
|
(self.filenames, os.listdir,),
|
||||||
(self.filenames, os.rename, "dst"),
|
(self.filenames, os.rename, "dst"),
|
||||||
(self.filenames, os.replace, "dst"),
|
(self.filenames, os.replace, "dst"),
|
||||||
|
(self.filenames, os.utime, None),
|
||||||
]
|
]
|
||||||
if os_helper.can_chmod():
|
if os_helper.can_chmod():
|
||||||
funcs.append((self.filenames, os.chmod, 0o777))
|
funcs.append((self.filenames, os.chmod, 0o777))
|
||||||
|
|
@ -4120,6 +4121,19 @@ def test_oserror_filename(self):
|
||||||
else:
|
else:
|
||||||
self.fail(f"No exception thrown by {func}")
|
self.fail(f"No exception thrown by {func}")
|
||||||
|
|
||||||
|
def test_mkdir(self):
|
||||||
|
filename = os_helper.TESTFN
|
||||||
|
subdir = os.path.join(filename, 'subdir')
|
||||||
|
self.assertRaises(FileNotFoundError, os.mkdir, subdir)
|
||||||
|
|
||||||
|
self.addCleanup(os_helper.unlink, filename)
|
||||||
|
create_file(filename)
|
||||||
|
self.assertRaises(FileExistsError, os.mkdir, filename)
|
||||||
|
|
||||||
|
self.assertRaises((NotADirectoryError, FileNotFoundError),
|
||||||
|
os.mkdir, subdir)
|
||||||
|
|
||||||
|
|
||||||
class CPUCountTests(unittest.TestCase):
|
class CPUCountTests(unittest.TestCase):
|
||||||
def check_cpu_count(self, cpus):
|
def check_cpu_count(self, cpus):
|
||||||
if cpus is None:
|
if cpus is None:
|
||||||
|
|
|
||||||
|
|
@ -21,41 +21,6 @@
|
||||||
from .utils import create_file
|
from .utils import create_file
|
||||||
|
|
||||||
|
|
||||||
class Win32ErrorTests(unittest.TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
try:
|
|
||||||
os.stat(os_helper.TESTFN)
|
|
||||||
except FileNotFoundError:
|
|
||||||
exists = False
|
|
||||||
except OSError as exc:
|
|
||||||
exists = True
|
|
||||||
self.fail("file %s must not exist; os.stat failed with %s"
|
|
||||||
% (os_helper.TESTFN, exc))
|
|
||||||
else:
|
|
||||||
self.fail("file %s must not exist" % os_helper.TESTFN)
|
|
||||||
|
|
||||||
def test_rename(self):
|
|
||||||
self.assertRaises(OSError, os.rename, os_helper.TESTFN, os_helper.TESTFN+".bak")
|
|
||||||
|
|
||||||
def test_remove(self):
|
|
||||||
self.assertRaises(OSError, os.remove, os_helper.TESTFN)
|
|
||||||
|
|
||||||
def test_chdir(self):
|
|
||||||
self.assertRaises(OSError, os.chdir, os_helper.TESTFN)
|
|
||||||
|
|
||||||
def test_mkdir(self):
|
|
||||||
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
|
||||||
|
|
||||||
with open(os_helper.TESTFN, "x") as f:
|
|
||||||
self.assertRaises(OSError, os.mkdir, os_helper.TESTFN)
|
|
||||||
|
|
||||||
def test_utime(self):
|
|
||||||
self.assertRaises(OSError, os.utime, os_helper.TESTFN, None)
|
|
||||||
|
|
||||||
def test_chmod(self):
|
|
||||||
self.assertRaises(OSError, os.chmod, os_helper.TESTFN, 0)
|
|
||||||
|
|
||||||
|
|
||||||
class Win32KillTests(unittest.TestCase):
|
class Win32KillTests(unittest.TestCase):
|
||||||
def _kill(self, sig):
|
def _kill(self, sig):
|
||||||
# Start sys.executable as a subprocess and communicate from the
|
# Start sys.executable as a subprocess and communicate from the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue