Back to index

python3.2  3.2.2
Public Member Functions
test.test_os.MakedirTests Class Reference

List of all members.

Public Member Functions

def setUp
def test_makedir
def test_exist_ok_existing_directory
def test_exist_ok_existing_regular_file
def tearDown

Detailed Description

Definition at line 534 of file test_os.py.


Member Function Documentation

Definition at line 535 of file test_os.py.

00535 
00536     def setUp(self):
00537         os.mkdir(support.TESTFN)

Here is the caller graph for this function:

Definition at line 575 of file test_os.py.

00575 
00576     def tearDown(self):
00577         path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',
00578                             'dir4', 'dir5', 'dir6')
00579         # If the tests failed, the bottom-most directory ('../dir6')
00580         # may not have been created, so we look for the outermost directory
00581         # that exists.
00582         while not os.path.exists(path) and path != support.TESTFN:
00583             path = os.path.dirname(path)
00584 
00585         os.removedirs(path)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 553 of file test_os.py.

00553 
00554     def test_exist_ok_existing_directory(self):
00555         path = os.path.join(support.TESTFN, 'dir1')
00556         mode = 0o777
00557         old_mask = os.umask(0o022)
00558         os.makedirs(path, mode)
00559         self.assertRaises(OSError, os.makedirs, path, mode)
00560         self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False)
00561         self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True)
00562         os.makedirs(path, mode=mode, exist_ok=True)
00563         os.umask(old_mask)

Here is the call graph for this function:

Definition at line 564 of file test_os.py.

00564 
00565     def test_exist_ok_existing_regular_file(self):
00566         base = support.TESTFN
00567         path = os.path.join(support.TESTFN, 'dir1')
00568         f = open(path, 'w')
00569         f.write('abc')
00570         f.close()
00571         self.assertRaises(OSError, os.makedirs, path)
00572         self.assertRaises(OSError, os.makedirs, path, exist_ok=False)
00573         self.assertRaises(OSError, os.makedirs, path, exist_ok=True)
00574         os.remove(path)

Here is the call graph for this function:

Definition at line 538 of file test_os.py.

00538 
00539     def test_makedir(self):
00540         base = support.TESTFN
00541         path = os.path.join(base, 'dir1', 'dir2', 'dir3')
00542         os.makedirs(path)             # Should work
00543         path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4')
00544         os.makedirs(path)
00545 
00546         # Try paths with a '.' in them
00547         self.assertRaises(OSError, os.makedirs, os.curdir)
00548         path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4', 'dir5', os.curdir)
00549         os.makedirs(path)
00550         path = os.path.join(base, 'dir1', os.curdir, 'dir2', 'dir3', 'dir4',
00551                             'dir5', 'dir6')
00552         os.makedirs(path)

Here is the call graph for this function:


The documentation for this class was generated from the following file: