diff options
author | Brett Cannon <bcannon@gmail.com> | 2004-06-19 21:11:35 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2004-06-19 21:11:35 (GMT) |
commit | 1c3fa18be76d1bcddb2de516913f46a32c5ed860 (patch) | |
tree | 475daa275d1e5576db99336f2397f6318f0275ea /Lib/test/test_shutil.py | |
parent | b46ed71d706d2f94552e13664c08706421263856 (diff) | |
download | cpython-1c3fa18be76d1bcddb2de516913f46a32c5ed860.zip cpython-1c3fa18be76d1bcddb2de516913f46a32c5ed860.tar.gz cpython-1c3fa18be76d1bcddb2de516913f46a32c5ed860.tar.bz2 |
shutil.move() will raise an exception when trying to move a directory into
itself.
Closes bug #919012 . Thanks Johannes Gijsbers.
Diffstat (limited to 'Lib/test/test_shutil.py')
-rw-r--r-- | Lib/test/test_shutil.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index 3a39ec9..05f34d8 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -3,6 +3,8 @@ import unittest import shutil import tempfile +import os +import os.path from test import test_support class TestShutil(unittest.TestCase): @@ -12,11 +14,21 @@ class TestShutil(unittest.TestCase): self.assertRaises(OSError, shutil.rmtree, filename) self.assertEqual(shutil.rmtree(filename, True), None) + def test_dont_move_dir_in_itself(self): + src_dir = tempfile.mkdtemp() + try: + dst = os.path.join(src_dir, 'foo') + self.assertRaises(shutil.Error, shutil.move, src_dir, dst) + finally: + try: + os.rmdir(src_dir) + except: + pass + + - def test_main(): test_support.run_unittest(TestShutil) - if __name__ == '__main__': test_main() |