From: Victor Stinner Date: Mon, 14 Mar 2016 16:47:03 +0000 (+0100) Subject: Skip test_site if USER_SITE cannot be created X-Git-Tag: v3.6.0a1~480^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21d0e1b5fcc5a02a90f2424028d64a551d224d74;p=python 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 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.