From 60bf287a37358792277b5c1a0ba6821e579b97da Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Sun, 30 Dec 2018 16:09:22 +0100 Subject: Make sure the test does not crash if the directory already exists --- astroid/tests/unittest_modutils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/astroid/tests/unittest_modutils.py b/astroid/tests/unittest_modutils.py index eb569935..ae4ac245 100644 --- a/astroid/tests/unittest_modutils.py +++ b/astroid/tests/unittest_modutils.py @@ -168,10 +168,13 @@ class ModPathFromFileTest(unittest.TestCase): # /tmp/path_to_include (symlink to /tmp/deployment) # /tmp/secret.py # /tmp/deployment/secret.py (points to /tmp/secret.py) - os.mkdir(deployment_path) - self.addCleanup(shutil.rmtree, deployment_path) - os.symlink(deployment_path, path_to_include) - self.addCleanup(os.remove, path_to_include) + try: + os.mkdir(deployment_path) + self.addCleanup(shutil.rmtree, deployment_path) + os.symlink(deployment_path, path_to_include) + self.addCleanup(os.remove, path_to_include) + except OSError: + pass with open(real_secret_path, "w"): pass os.symlink(real_secret_path, symlink_secret_path) -- cgit v1.2.1