blob: 05f34d84665689252c85122dee1495bc178e8df9 [file] [log] [blame]
Barry Warsaw7fc2cca2003-01-24 17:34:13 +00001# Copyright (C) 2003 Python Software Foundation
2
3import unittest
4import shutil
5import tempfile
Brett Cannon1c3fa182004-06-19 21:11:35 +00006import os
7import os.path
Barry Warsaw7fc2cca2003-01-24 17:34:13 +00008from test import test_support
9
10class TestShutil(unittest.TestCase):
11 def test_rmtree_errors(self):
12 # filename is guaranteed not to exist
13 filename = tempfile.mktemp()
14 self.assertRaises(OSError, shutil.rmtree, filename)
15 self.assertEqual(shutil.rmtree(filename, True), None)
16
Brett Cannon1c3fa182004-06-19 21:11:35 +000017 def test_dont_move_dir_in_itself(self):
18 src_dir = tempfile.mkdtemp()
19 try:
20 dst = os.path.join(src_dir, 'foo')
21 self.assertRaises(shutil.Error, shutil.move, src_dir, dst)
22 finally:
23 try:
24 os.rmdir(src_dir)
25 except:
26 pass
Barry Warsaw7fc2cca2003-01-24 17:34:13 +000027
Brett Cannon1c3fa182004-06-19 21:11:35 +000028
29
Barry Warsaw7fc2cca2003-01-24 17:34:13 +000030def test_main():
Walter Dörwald21d3a322003-05-01 17:45:56 +000031 test_support.run_unittest(TestShutil)
Barry Warsaw7fc2cca2003-01-24 17:34:13 +000032
Barry Warsaw7fc2cca2003-01-24 17:34:13 +000033if __name__ == '__main__':
Walter Dörwald21d3a322003-05-01 17:45:56 +000034 test_main()