# my_module.py
def walk_error_handler(os_error_instance):
logger.error(...)
for root, dirs, files in os.walk(path, onerror=walk_error_handler):
...
How to unit test that os.walk
, should it encounter an OSError
, calls the custom handler?
I tried to do this by creating a temporary file in a temporary directory, and then restricting the permissions of the directory. Unfortunately that crashed the test runner. Looking for a more elegant solution.
Aucun commentaire:
Enregistrer un commentaire