]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #19828: Fixed test_site when the whole suite is run with -S.
authorZachary Ware <zachary.ware@gmail.com>
Wed, 11 Dec 2013 22:59:44 +0000 (16:59 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Wed, 11 Dec 2013 22:59:44 +0000 (16:59 -0600)
Also, cleaned up an unused import.

Lib/test/test_site.py
Misc/NEWS

index ad4f3ec84909d247d7df8a7cd479c20a9ab4bf24..f3bd168168319f2be5cc6c9f3ccfe096c6b8d201 100644 (file)
@@ -6,8 +6,7 @@ executing have not been removed.
 """
 import unittest
 import test.support
-from test.support import run_unittest, TESTFN, EnvironmentVarGuard
-from test.support import captured_stderr
+from test.support import captured_stderr, TESTFN, EnvironmentVarGuard
 import builtins
 import os
 import sys
@@ -19,13 +18,13 @@ import subprocess
 import sysconfig
 from copy import copy
 
-# Need to make sure to not import 'site' if someone specified ``-S`` at the
-# command-line.  Detect this by just making sure 'site' has not been imported
-# already.
-if "site" in sys.modules:
-    import site
-else:
-    raise unittest.SkipTest("importation of site.py suppressed")
+# These tests are not particularly useful if Python was invoked with -S.
+# If you add tests that are useful under -S, this skip should be moved
+# to the class level.
+if sys.flags.no_site:
+    raise unittest.SkipTest("Python was invoked with -S")
+
+import site
 
 if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
     # need to add user site directory for tests
index be8ce2546c326cb3d905044aa1bdf5eb520c1703..35e7a06a1f185072917d79e591e23ce4bc69b477 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -130,6 +130,8 @@ IDLE
 Tests
 -----
 
+- Issue #19828: Fixed test_site when the whole suite is run with -S.
+
 - Issue #19928: Implemented a test for repr() of cell objects.
 
 - Issue #19535: Fixed test_docxmlrpc when python is run with -OO.