diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2003-12-23 16:36:11 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2003-12-23 16:36:11 (GMT) |
commit | b386f6a50993f49fb62180c5a1e2a562a97cb368 (patch) | |
tree | ca708911585df9301b462d1668669578afb2b38b /Lib/test/test_os.py | |
parent | 6fccc8a9ec17a97c51875bcde532d3b8e5ebaedd (diff) | |
download | cpython-b386f6a50993f49fb62180c5a1e2a562a97cb368.zip cpython-b386f6a50993f49fb62180c5a1e2a562a97cb368.tar.gz cpython-b386f6a50993f49fb62180c5a1e2a562a97cb368.tar.bz2 |
As part of fixing bug #829532, add a test case that exercises os.makedirs
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index d5f4774..221571a 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -301,12 +301,47 @@ class WalkTests(unittest.TestCase): os.rmdir(join(root, name)) os.rmdir(test_support.TESTFN) +class MakedirTests (unittest.TestCase): + def setUp(self): + os.mkdir(test_support.TESTFN) + + def test_makedir(self): + base = test_support.TESTFN + path = os.path.join(base, 'dir1', 'dir2', 'dir3') + os.makedirs(path) # Should work + path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4') + os.makedirs(path) + + # Try paths with a '.' in them + self.failUnlessRaises(OSError, os.makedirs, os.curdir) + path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir) + os.makedirs(path) + path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4', + 'dir5', 'dir6') + os.makedirs(path) + + + + + def tearDown(self): + path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3', + 'dir4', 'dir5', 'dir6') + # If the tests failed, the bottom-most directory ('../dir6') + # may not have been created, so we look for the outermost directory + # that exists. + while not os.path.exists(path) and path != test_support.TESTFN: + path = os.path.dirname(path) + + os.removedirs(path) + + def test_main(): test_support.run_unittest( TemporaryFileTests, StatAttributeTests, EnvironTests, - WalkTests + WalkTests, + MakedirTests, ) if __name__ == "__main__": |