Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21d0e1b

Browse files
committed
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.
1 parent 8c0f0c5 commit 21d0e1b

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/test/test_site.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828

2929
if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
3030
# need to add user site directory for tests
31-
os.makedirs(site.USER_SITE)
32-
site.addsitedir(site.USER_SITE)
31+
try:
32+
os.makedirs(site.USER_SITE)
33+
site.addsitedir(site.USER_SITE)
34+
except PermissionError as exc:
35+
raise unittest.SkipTest('unable to create user site directory (%r): %s'
36+
% (site.USER_SITE, exc))
37+
3338

3439
class HelperFunctionsTests(unittest.TestCase):
3540
"""Tests for helper functions.

0 commit comments

Comments
 (0)