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.
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 0898449..78c4809 100644
--- 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.