From 4d0d2d0d6ff2dc61e5eea4507014d4099118f30c Mon Sep 17 00:00:00 2001 From: leahwicz <60146280+leahwicz@users.noreply.github.com> Date: Thu, 2 Dec 2021 15:33:10 -0500 Subject: [PATCH] Add windows OS error supressing for temp dir cleanups (#4380) (#4398) Co-authored-by: Ian Knox <81931810+iknox-fa@users.noreply.github.com> --- .../test_cli_invocation.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/integration/015_cli_invocation_tests/test_cli_invocation.py b/test/integration/015_cli_invocation_tests/test_cli_invocation.py index ef898ae84fe..c4625055de4 100644 --- a/test/integration/015_cli_invocation_tests/test_cli_invocation.py +++ b/test/integration/015_cli_invocation_tests/test_cli_invocation.py @@ -41,9 +41,17 @@ def temporary_working_directory() -> str: out : str The temporary working directory. """ - with tempfile.TemporaryDirectory() as tmpdir: - with change_working_directory(tmpdir): - yield tmpdir + # N.B: supressing the OSError is necessary for older (pre 3.10) versions of python + # which do not support the `ignore_cleanup_errors` in tempfile::TemporaryDirectory. + # See: https://github.com/python/cpython/pull/24793 + # + # In our case the cleanup is redundent since windows handles clearing + # Appdata/Local/Temp at the os level anyway. + + with contextlib.suppress(OSError): + with tempfile.TemporaryDirectory() as tmpdir: + with change_working_directory(tmpdir): + yield tmpdir def get_custom_profiles_config(database_host, custom_schema):