Revision 76e5f8b5 test/ganeti.utils_unittest.py
b/test/ganeti.utils_unittest.py | ||
---|---|---|
1504 | 1504 |
self.assertEqual(validity, (None, None)) |
1505 | 1505 |
|
1506 | 1506 |
|
1507 |
class TestMakedirs(unittest.TestCase): |
|
1508 |
def setUp(self): |
|
1509 |
self.tmpdir = tempfile.mkdtemp() |
|
1510 |
|
|
1511 |
def tearDown(self): |
|
1512 |
shutil.rmtree(self.tmpdir) |
|
1513 |
|
|
1514 |
def testNonExisting(self): |
|
1515 |
path = utils.PathJoin(self.tmpdir, "foo") |
|
1516 |
utils.Makedirs(path) |
|
1517 |
self.assert_(os.path.isdir(path)) |
|
1518 |
|
|
1519 |
def testExisting(self): |
|
1520 |
path = utils.PathJoin(self.tmpdir, "foo") |
|
1521 |
os.mkdir(path) |
|
1522 |
utils.Makedirs(path) |
|
1523 |
self.assert_(os.path.isdir(path)) |
|
1524 |
|
|
1525 |
def testRecursiveNonExisting(self): |
|
1526 |
path = utils.PathJoin(self.tmpdir, "foo/bar/baz") |
|
1527 |
utils.Makedirs(path) |
|
1528 |
self.assert_(os.path.isdir(path)) |
|
1529 |
|
|
1530 |
def testRecursiveExisting(self): |
|
1531 |
path = utils.PathJoin(self.tmpdir, "B/moo/xyz") |
|
1532 |
self.assert_(not os.path.exists(path)) |
|
1533 |
os.mkdir(utils.PathJoin(self.tmpdir, "B")) |
|
1534 |
utils.Makedirs(path) |
|
1535 |
self.assert_(os.path.isdir(path)) |
|
1536 |
|
|
1537 |
|
|
1507 | 1538 |
if __name__ == '__main__': |
1508 | 1539 |
testutils.GanetiTestProgram() |
Also available in: Unified diff