summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-14 17:47:03 +0100
committerVictor Stinner <victor.stinner@gmail.com>2016-03-14 17:47:03 +0100
commitf39a08e99c5a5e10f8d8feddeb85a8c9a33a3ddb (patch)
tree46aeda7788b58a3eba66737041637bd7cfc114ce
parentbe85c5cdf8af23a2fbc440423fa7ca9d73812051 (diff)
downloadcpython-f39a08e99c5a5e10f8d8feddeb85a8c9a33a3ddb.tar.gz
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.
-rw-r--r--Lib/test/test_site.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 6615080c46..da20a3d21a 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -28,8 +28,13 @@ import site
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 PermissionError 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.