diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2018-12-30 16:09:22 +0100 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2018-12-30 16:12:29 +0100 |
| commit | 60bf287a37358792277b5c1a0ba6821e579b97da (patch) | |
| tree | e1735b9395377507bcc1e9c77a3807d8d631515d | |
| parent | 9288bd291be1abb74f40df4611bad63252e89cd0 (diff) | |
| download | astroid-git-60bf287a37358792277b5c1a0ba6821e579b97da.tar.gz | |
Make sure the test does not crash if the directory already exists
| -rw-r--r-- | astroid/tests/unittest_modutils.py | 11 |
1 files 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) |
