Implement os.{chdir,rename,rmdir,remove} using Win32 directly.
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 2bc5fc0..5bb45f5 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -5,6 +5,7 @@
import os
import unittest
import warnings
+import sys
from test import test_support
warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
@@ -364,6 +365,20 @@
except NotImplementedError:
pass
+class Win32ErrorTests(unittest.TestCase):
+ def test_rename(self):
+ self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak")
+
+ def test_remove(self):
+ self.assertRaises(WindowsError, os.remove, test_support.TESTFN)
+
+ def test_chdir(self):
+ self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
+
+if sys.platform != 'win32':
+ class Win32ErrorTests(unittest.TestCase):
+ pass
+
def test_main():
test_support.run_unittest(
TemporaryFileTests,
@@ -372,7 +387,8 @@
WalkTests,
MakedirTests,
DevNullTests,
- URandomTests
+ URandomTests,
+ Win32ErrorTests
)
if __name__ == "__main__":
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 7c28602..6ab5a35 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -48,12 +48,12 @@
if self.errorState == 0:
self.assertEqual(func, os.remove)
self.assertEqual(arg, self.childpath)
- self.assertEqual(exc[0], OSError)
+ self.failUnless(issubclass(exc[0], OSError))
self.errorState = 1
else:
self.assertEqual(func, os.rmdir)
self.assertEqual(arg, TESTFN)
- self.assertEqual(exc[0], OSError)
+ self.failUnless(issubclass(exc[0], OSError))
self.errorState = 2
def test_rmtree_dont_delete_file(self):