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

Skip to content

Commit 36193e7

Browse files
committed
Issue #19828: Fixed test_site when the whole suite is run with -S.
Also, cleaned up an unused import.
1 parent d5c4c74 commit 36193e7

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

Lib/test/test_site.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"""
77
import unittest
88
import test.support
9-
from test.support import run_unittest, TESTFN, EnvironmentVarGuard
10-
from test.support import captured_stderr
9+
from test.support import captured_stderr, TESTFN, EnvironmentVarGuard
1110
import builtins
1211
import os
1312
import sys
@@ -19,13 +18,13 @@
1918
import sysconfig
2019
from copy import copy
2120

22-
# Need to make sure to not import 'site' if someone specified ``-S`` at the
23-
# command-line. Detect this by just making sure 'site' has not been imported
24-
# already.
25-
if "site" in sys.modules:
26-
import site
27-
else:
28-
raise unittest.SkipTest("importation of site.py suppressed")
21+
# These tests are not particularly useful if Python was invoked with -S.
22+
# If you add tests that are useful under -S, this skip should be moved
23+
# to the class level.
24+
if sys.flags.no_site:
25+
raise unittest.SkipTest("Python was invoked with -S")
26+
27+
import site
2928

3029
if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
3130
# need to add user site directory for tests

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ IDLE
130130
Tests
131131
-----
132132

133+
- Issue #19828: Fixed test_site when the whole suite is run with -S.
134+
133135
- Issue #19928: Implemented a test for repr() of cell objects.
134136

135137
- Issue #19535: Fixed test_docxmlrpc when python is run with -OO.

0 commit comments

Comments
 (0)