[Python-checkins] python/dist/src/Lib/test test_os.py,1.19,1.20

akuchling at users.sourceforge.net akuchling at users.sourceforge.net
Tue Dec 23 11:36:18 EST 2003


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv7678

Modified Files:
	test_os.py 
Log Message:
As part of fixing bug #829532, add a test case that exercises os.makedirs


Index: test_os.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_os.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** test_os.py	20 Oct 2003 14:01:51 -0000	1.19
--- test_os.py	23 Dec 2003 16:36:11 -0000	1.20
***************
*** 302,305 ****
--- 302,339 ----
          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(
***************
*** 307,311 ****
          StatAttributeTests,
          EnvironTests,
!         WalkTests
      )
  
--- 341,346 ----
          StatAttributeTests,
          EnvironTests,
!         WalkTests,
!         MakedirTests,
      )
  





More information about the Python-checkins mailing list