def test_clean(self): tf = Tempfiles() dir = tf.mkdir("goob") self.assertTrue(os.path.exists(dir)) f = tf.track("goob/junk.txt") self.assertEqual(f, os.path.join(dir, "junk.txt")) with open(f, 'w') as fd: fd.write("Hello world!\n") self.assertTrue(os.path.exists(f)) tf.clean() self.assertFalse(os.path.exists(f)) self.assertFalse(os.path.exists(dir)) self.assertTrue(os.path.exists(tf.root))
def test_mkdir(self): tf = Tempfiles() path = tf.mkdir("goob") self.assertEqual(path, os.path.join(tf.root, "goob")) self.assertTrue(os.path.exists(tf.root)) self.assertTrue(os.path.exists(path))
def test_ctor(self): tf = Tempfiles() self.assertEqual(tf.root, tmpdir()) self.assertTrue(os.path.exists(tf.root)) self.assertFalse(tf._autoclean) self.assertEqual(len(tf._files), 0)