Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d60e92a

Browse files
author
Johannes Gijsbers
committed
Document not-completely-obvious behavior in a test.
1 parent 6ab4b99 commit d60e92a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_shutil.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ def test_rmtree_errors(self):
1616
self.assertEqual(shutil.rmtree(filename, True), None)
1717
shutil.rmtree(filename, False, lambda func, arg, exc: None)
1818

19+
def test_rmtree_dont_delete_file(self):
20+
# When called on a file instead of a directory, don't delete it.
21+
handle, path = tempfile.mkstemp()
22+
os.fdopen(handle).close()
23+
self.assertRaises(OSError, shutil.rmtree, path)
24+
os.remove(path)
25+
1926
def test_dont_move_dir_in_itself(self):
2027
src_dir = tempfile.mkdtemp()
2128
try:

0 commit comments

Comments
 (0)