]> granicus.if.org Git - python/commitdiff
Skip test_site if USER_SITE cannot be created
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 14 Mar 2016 16:49:46 +0000 (17:49 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 14 Mar 2016 16:49:46 +0000 (17:49 +0100)
Issue #17758: Skip test_site if site.USER_SITE directory doesn't exist and
cannot be created.

Lib/test/test_site.py

index 0898449a1827739a62f2e94f960cebe8ce3318ad..78c48094e4b57daa5b3e93c0aa969cdf6f6d561e 100644 (file)
@@ -26,8 +26,13 @@ else:
 
 if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
     # need to add user site directory for tests
-    os.makedirs(site.USER_SITE)
-    site.addsitedir(site.USER_SITE)
+    try:
+        os.makedirs(site.USER_SITE)
+        site.addsitedir(site.USER_SITE)
+    except OSError as exc:
+        raise unittest.SkipTest('unable to create user site directory (%r): %s'
+                                % (site.USER_SITE, exc))
+
 
 class HelperFunctionsTests(unittest.TestCase):
     """Tests for helper functions.