Staging
v0.8.1
swh:1:snp:635f4099902912592851108bcac178ff574f7c5f
Raw File
Tip revision: cb6727e8118d24d0fb65ef60dec5f512a58c1f46 authored by Martin v. Löwis on 02 March 2008, 20:39:32 UTC
Prepare for 2.3.7c1.
Tip revision: cb6727e
test_shutil.py
# Copyright (C) 2003 Python Software Foundation

import unittest
import shutil
import tempfile
import os
import os.path
from test import test_support

class TestShutil(unittest.TestCase):
    def test_rmtree_errors(self):
        # filename is guaranteed not to exist
        filename = tempfile.mktemp()
        self.assertRaises(OSError, shutil.rmtree, filename)
        self.assertEqual(shutil.rmtree(filename, True), None)
        shutil.rmtree(filename, False, lambda func, arg, exc: 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()
back to top