jeudi 9 janvier 2020

How do I monkeypatch a file system directory without assuming too much about the implementation?

I often see examples of how to use pytests monkey patch to modify methods in the os.path module, to redirect input/output to a temporary directory. An example is found here: Answer to "How do I mock the filesystem in Python unit tests?"

This kind of monkey patching assumes that the implementation uses the expanduser method. What if it for some reason uses the HOME environmental variable?

Is there a way to avoid making these assumptions?

Aucun commentaire:

Enregistrer un commentaire