Skip to content

local_filesystem_mock

This submodule implements the LocalFilesystemMock and LocalFileMock classes.

LocalFileMock

This class mocks a file in the local filesystem.

Source code in src/paramiko_mock/local_filesystem_mock.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class LocalFileMock():
    """
    This class mocks a file in the local filesystem.
    """
    write_history: list[Any] = []
    file_content: Any = None

    def write(self, data: Any) -> None:
        self.write_history.append(data)
        if self.file_content is None:
            self.file_content = data
        else:
            self.file_content += data

LocalFilesystemMock

LocalFilesystemMock is a class that stores the mocked local filesystem. This is mainly an internal class and should not be used directly.

Source code in src/paramiko_mock/local_filesystem_mock.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class LocalFilesystemMock():
    """
    LocalFilesystemMock is a class that stores the mocked local filesystem.
    __This is mainly an internal class and should not be used directly.__
    """
    file_system: dict[str, LocalFileMock] = {}

    def add_file(self, path: str, file_mock: LocalFileMock) -> None:
        self.file_system[path] = file_mock

    def get_file(self, path: str) -> LocalFileMock | None:
        return self.file_system.get(path)

    def remove_file(self, path: str) -> None:
        self.file_system.pop(path, None)