test_runner: Add error handling for test directory clean up.

It was discovered that errors such as:
    `OSError: [Errno 16] Device or resource busy`
potentially arise when running in serial mode, or with
explicit test cases passed to `test-backend`.
This commit is contained in:
Wyatt Hoodes
2019-07-14 14:10:56 -10:00
committed by Tim Abbott
parent 94bbc32a92
commit c218735b2c

View File

@@ -479,8 +479,11 @@ class Runner(DiscoverRunner):
os.remove(filepath)
# Clean up our test runs root directory.
if os.path.exists(TEST_RUN_DIR):
try:
shutil.rmtree(TEST_RUN_DIR)
except OSError:
print("Unable to clean up the test run's directory.")
pass
return super().teardown_test_environment(*args, **kwargs)
def test_imports(self, test_labels: List[str], suite: unittest.TestSuite) -> None: