Beispiel #1
0
 def test_tmpdir1(self):
     """simple temporary directory"""
     tmpdir = TemporaryDirectory(dir=self._tmpdir)
     path = tmpdir.path
     self.assertIsNotNone(path)
     self.assertTrue(os.path.isdir(path))
     self.assertEqual(str(tmpdir), path)
     # a simple assignment to path is not supposed to work, but _path
     # can still be modified (_never_ do that)
     self.assertRaises(AttributeError, setattr, tmpdir, 'path', path)
     tmpdir.rmtree()
     self.assertIsNone(tmpdir.path)
     self.assertFalse(os.path.isdir(path))
Beispiel #2
0
 def test_tmpdir1(self):
     """simple temporary directory"""
     tmpdir = TemporaryDirectory(dir=self._tmpdir)
     path = tmpdir.path
     self.assertIsNotNone(path)
     self.assertTrue(os.path.isdir(path))
     self.assertEqual(str(tmpdir), path)
     # a simple assignment to path is not supposed to work, but _path
     # can still be modified (_never_ do that)
     self.assertRaises(AttributeError, setattr, tmpdir, 'path', path)
     tmpdir.rmtree()
     self.assertIsNone(tmpdir.path)
     self.assertFalse(os.path.isdir(path))
Beispiel #3
0
 def test_tmpdir3(self):
     """multiple remove"""
     tmpdir = TemporaryDirectory(dir=self._tmpdir)
     path = tmpdir.path
     self.assertIsNotNone(path)
     self.assertTrue(os.path.isdir(path))
     tmpdir.rmtree()
     self.assertFalse(os.path.isdir(path))
     # a call to path does not recreate the tmpdir
     self.assertIsNone(tmpdir.path)
     self.assertFalse(os.path.isdir(path))
     # recreate directory
     os.mkdir(path)
     self.assertTrue(os.path.isdir(path))
     # subsequent rmdir/rmtree calls have no affect anymore
     tmpdir.rmdir()
     tmpdir.rmtree()
     self.assertTrue(os.path.isdir(path))
     os.rmdir(path)
Beispiel #4
0
 def test_tmpdir3(self):
     """multiple remove"""
     tmpdir = TemporaryDirectory(dir=self._tmpdir)
     path = tmpdir.path
     self.assertIsNotNone(path)
     self.assertTrue(os.path.isdir(path))
     tmpdir.rmtree()
     self.assertFalse(os.path.isdir(path))
     # a call to path does not recreate the tmpdir
     self.assertIsNone(tmpdir.path)
     self.assertFalse(os.path.isdir(path))
     # recreate directory
     os.mkdir(path)
     self.assertTrue(os.path.isdir(path))
     # subsequent rmdir/rmtree calls have no affect anymore
     tmpdir.rmdir()
     tmpdir.rmtree()
     self.assertTrue(os.path.isdir(path))
     os.rmdir(path)
Beispiel #5
0
 def test_tmpdir9(self):
     """test __enter__ (tmpdir was already deleted)"""
     tmpdir = TemporaryDirectory(dir=self._tmpdir)
     tmpdir.rmtree()
     self.assertIsNone(tmpdir.path)
     self.assertRaises(ValueError, tmpdir.__enter__)
Beispiel #6
0
 def test_tmpdir9(self):
     """test __enter__ (tmpdir was already deleted)"""
     tmpdir = TemporaryDirectory(dir=self._tmpdir)
     tmpdir.rmtree()
     self.assertIsNone(tmpdir.path)
     self.assertRaises(ValueError, tmpdir.__enter__)