INNER CODE UNIT · Python

mock_system

logandk/serverless-wsgi · requirements_test.py:43

def mock_system(monkeypatch):
    calls = []

    def mock_any(func, retval, *args, **kwargs):
        calls.append((func, args))
        if hasattr(retval, "__call__"):
            return retval(*args)
        else:
            return retval

    monkeypatch.setattr(
        os, "listdir", partial(mock_any, "os.listdir", ["dir1", "dir2", "file1"])
    )
    monkeypatch.setattr(os, "mkdir", partial(mock_any, "os.mkdir", None))
    monkeypatch.setattr(os, "remove", partial(mock_any, "os.remove", None))
    monkeypatch.setattr(os.path, "isfile", partial(mock_any, "os.path.isfile", True))
    monkeypatch.setattr(
        os.path,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…