Esempio n. 1
0
	def testSafeMakeDirs(self):
		parent = "testdirnoexist"
		subdir = os.path.join(parent, "somesubdir")
		subfile = os.path.join(subdir, "file.txt")
		if os.path.exists(subdir): os.removedirs(subdir)
		self.assertFalse(os.path.exists(parent))
		self.assertFalse(os.path.exists(subdir))
		self.assertEqual(subdir, fsu.safeMakedirs(subfile))
		# run again to make sure it doesn't choke
		self.assertEqual(subdir, fsu.safeMakedirs(subfile))
		self.assertTrue(os.path.exists(parent))
		self.assertTrue(os.path.exists(subdir))
		if os.path.exists(subdir): os.removedirs(subdir)
Esempio n. 2
0
	def testSafeMakeDirsBad(self):
		self.assertRaises(OSError, lambda: fsu.safeMakedirs(""))
		self.assertRaises(OSError, lambda: fsu.safeMakedirs(None))