コード例 #1
0
ファイル: mock_test.py プロジェクト: srirampmalladi/luigi
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")))
コード例 #2
0
 def tearDown(self):
     MockFileSystem().remove('')
コード例 #3
0
 def test_SuffixPreservingLocalTarget(self):
     _suffix = ".pth"
     temporary = tempfile.NamedTemporaryFile(suffix=_suffix)
     mockfilesystem = MockFileSystem()
     mocktarget = MockTarget(mockfilesystem)
     x = SuffixPreservingLocalTarget(temporary.name)
コード例 #4
0
 def setUp(self) -> None:
     MockFileSystem().clear()