]> granicus.if.org Git - python/commitdiff
Document not-completely-obvious behavior in a test.
authorJohannes Gijsbers <jlg@dds.nl>
Sat, 11 Sep 2004 21:26:21 +0000 (21:26 +0000)
committerJohannes Gijsbers <jlg@dds.nl>
Sat, 11 Sep 2004 21:26:21 +0000 (21:26 +0000)
Lib/test/test_shutil.py

index 9e5f6ff0489607998e59542d69438b386a20beaf..f8367a60c20badfb60d9995e2d4831a0952d494f 100644 (file)
@@ -16,6 +16,13 @@ class TestShutil(unittest.TestCase):
         self.assertEqual(shutil.rmtree(filename, True), None)
         shutil.rmtree(filename, False, lambda func, arg, exc: None)
 
+    def test_rmtree_dont_delete_file(self):
+        # When called on a file instead of a directory, don't delete it.
+        handle, path = tempfile.mkstemp()
+        os.fdopen(handle).close()
+        self.assertRaises(OSError, shutil.rmtree, path)
+        os.remove(path)
+
     def test_dont_move_dir_in_itself(self):
         src_dir = tempfile.mkdtemp()
         try: