summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-05-04 10:08:42 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-05-04 10:08:42 (GMT)
commit8e0d494e416a5d143e01b3d05b47d832aae0dadf (patch)
treededb2767bcbd46156ea424fc348348825f00ed6f /Lib
parent777367103c9ab487fb74ce3f3ac8ea2701de328e (diff)
downloadcpython-8e0d494e416a5d143e01b3d05b47d832aae0dadf.zip
cpython-8e0d494e416a5d143e01b3d05b47d832aae0dadf.tar.gz
cpython-8e0d494e416a5d143e01b3d05b47d832aae0dadf.tar.bz2
Implement os.{chdir,rename,rmdir,remove} using Win32 directly.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_os.py18
-rw-r--r--Lib/test/test_shutil.py4
2 files changed, 19 insertions, 3 deletions
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 @@ class URandomTests (unittest.TestCase):
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 @@ def test_main():
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 @@ class TestShutil(unittest.TestCase):
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):