[Python-checkins] cpython (2.7): Skip test_site if USER_SITE cannot be created

victor.stinner python-checkins at python.org
Mon Mar 14 12:49:56 EDT 2016


https://hg.python.org/cpython/rev/1a40ee2bad6a
changeset:   100531:1a40ee2bad6a
branch:      2.7
parent:      100522:9f8db4d1e149
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Mon Mar 14 17:49:46 2016 +0100
summary:
  Skip test_site if USER_SITE cannot be created

Issue #17758: Skip test_site if site.USER_SITE directory doesn't exist and
cannot be created.

files:
  Lib/test/test_site.py |  9 +++++++--
  1 files changed, 7 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -26,8 +26,13 @@
 
 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.

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list