Skip to content

Commit

Permalink
try again?
Browse files Browse the repository at this point in the history
  • Loading branch information
csm10495 committed Sep 16, 2023
1 parent 8a14f39 commit b870a6f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Lib/test/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,12 @@ def test_customization_modules_on_startup(self):
# Check that sitecustomize and or usercustomize are executed on startup
mod_info = [
# func to get directory, file base name
('getusersitepackages', 'usercustomize'),
('getsitepackages', 'sitecustomize')
]

if not sys.flags.no_user_site:
mod_info.append(('getusersitepackages', 'usercustomize'),)

for func_name, module_name in mod_info:
# getusersitepackages returns a string.. getsitepackages returns a list..
# handle either way.
Expand All @@ -500,12 +502,8 @@ def test_customization_modules_on_startup(self):

eyecatcher = f'EXECUTED_{module_name}'

try:
with open(customize_path, 'w') as f:
f.write(f'print("{eyecatcher}")')
except PermissionError:
# Can't modify system site packages depending on the system configuration
continue
with open(customize_path, 'w') as f:
f.write(f'print("{eyecatcher}")')

output = subprocess.check_output([sys.executable, '-c', '""'])
self.assertIn(eyecatcher, output.decode('utf-8'))
Expand Down

0 comments on commit b870a6f

Please sign in to comment.