def test_ensure_dir(tc): dirname = os.path.join(tc.sandbox(), "sub") tc.assertFalse(os.path.exists(dirname)) utils.ensure_dir(dirname) tc.assertTrue(os.path.isdir(dirname)) utils.ensure_dir(dirname) tc.assertTrue(os.path.isdir(dirname)) with tc.assertRaises(EnvironmentError) as ar: utils.ensure_dir(os.path.join(tc.sandbox(), "nonex", "sub")) tc.assertEqual(ar.exception.errno, errno.ENOENT)
def _ensure_dir(self, pathname): # For overriding in the testsuite utils.ensure_dir(pathname)