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.
This commit is contained in:
Victor Stinner 2016-03-14 17:47:03 +01:00
parent 8c0f0c5c1e
commit 21d0e1b5fc
1 changed files with 7 additions and 2 deletions

View File

@ -28,8 +28,13 @@ import site
if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE): if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
# need to add user site directory for tests # need to add user site directory for tests
os.makedirs(site.USER_SITE) try:
site.addsitedir(site.USER_SITE) 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): class HelperFunctionsTests(unittest.TestCase):
"""Tests for helper functions. """Tests for helper functions.