tempdirs in test_main now cleanup without windows errors

This commit is contained in:
John-Mason P. Shackelford 2024-06-18 11:39:26 -04:00
parent f4e4e3af87
commit dd6a7964b6
No known key found for this signature in database
GPG key ID: B546E2175409B912
2 changed files with 10 additions and 4 deletions

View file

@ -17,11 +17,17 @@ class IgnorantTemporaryDirectory:
return self.temp_dir.__enter__()
def __exit__(self, exc_type, exc_val, exc_tb):
self.cleanup()
def cleanup(self):
try:
self.temp_dir.__exit__(exc_type, exc_val, exc_tb)
self.temp_dir.cleanup()
except (OSError, PermissionError):
pass # Ignore errors (Windows)
def __getattr__(self, item):
return getattr(self.temp_dir, item)
class ChdirTemporaryDirectory(IgnorantTemporaryDirectory):
def __init__(self):