Skip to content

Commit

Permalink
Fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
csm10495 committed Sep 16, 2023
1 parent c78aedd commit 22337a9
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Lib/test/test_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,25 +498,26 @@ def test_customization_modules_on_startup(self):
os.rename(customize_path, oldcustomize_path)
self.addCleanup(os.rename, oldcustomize_path, customize_path)

self.addCleanup(os.remove, customize_path)

eyecatcher = f'EXECUTED_{module_name}'

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'))
try:
with open(customize_path, 'w') as f:
f.write(f'print("{eyecatcher}")')

# -S blocks any site-packages
output = subprocess.check_output([sys.executable, '-S', '-c', '""'])
self.assertNotIn(eyecatcher, output.decode('utf-8'))
output = subprocess.check_output([sys.executable, '-c', '""'])
self.assertIn(eyecatcher, output.decode('utf-8'))

# -s blocks user site-packages
if 'usercustomize' == module_name:
output = subprocess.check_output([sys.executable, '-s', '-c', '""'])
# -S blocks any site-packages
output = subprocess.check_output([sys.executable, '-S', '-c', '""'])
self.assertNotIn(eyecatcher, output.decode('utf-8'))

# -s blocks user site-packages
if 'usercustomize' == module_name:
output = subprocess.check_output([sys.executable, '-s', '-c', '""'])
self.assertNotIn(eyecatcher, output.decode('utf-8'))
finally:
os.remove(customize_path)

@unittest.skipUnless(hasattr(urllib.request, "HTTPSHandler"),
'need SSL support to download license')
@test.support.requires_resource('network')
Expand Down

0 comments on commit 22337a9

Please sign in to comment.