class MockFileSystemTest(unittest.TestCase): fs = MockFileSystem() def _touch(self, path): t = MockFile(path) with t.open('w'): pass def setUp(self): self.fs.clear() self.path = "/tmp/foo" self.path2 = "/tmp/bar" self._touch(self.path) self._touch(self.path2) def test_exists(self): self.assertTrue(self.fs.exists(self.path)) def test_remove(self): self.fs.remove(self.path) self.assertFalse(self.fs.exists(self.path)) def test_remove_recursive(self): self.fs.remove("/tmp", recursive=True) self.assertFalse(self.fs.exists(self.path)) self.assertFalse(self.fs.exists(self.path2)) def test_listdir(self): self.assertEqual(sorted([self.path, self.path2]), sorted(self.fs.listdir("/tmp")))
def tearDown(self): MockFileSystem().remove('')
def test_SuffixPreservingLocalTarget(self): _suffix = ".pth" temporary = tempfile.NamedTemporaryFile(suffix=_suffix) mockfilesystem = MockFileSystem() mocktarget = MockTarget(mockfilesystem) x = SuffixPreservingLocalTarget(temporary.name)
def setUp(self) -> None: MockFileSystem().clear()