def monkeypatch_pathlib_import(monkeypatch, fs): """Patch pathlib.Path imports""" fake_pathlib = FakePathlibModule(fs) class PathMock: def __init__(self, *args, **kwargs): self.__delegate = fake_pathlib.Path(*args, **kwargs) def __getattr__(self, name): return getattr(self.__delegate, name) monkeypatch.setattr(conf_loading, "Path", PathMock)
def __init__(self, filesystem): if self.fake_pathlib is None: from pyfakefs.fake_pathlib import FakePathlibModule self.__class__.fake_pathlib = FakePathlibModule(filesystem)