diff options
author | Christian Heimes <christian@cheimes.de> | 2008-05-06 23:45:46 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-05-06 23:45:46 (GMT) |
commit | 8dc226fccd2183670ac19a85b89941f5b05167dc (patch) | |
tree | a02b3f53c54d1e18139d53de40954828350fabcb /Lib/test/test_site.py | |
parent | 1bf7108fd515af1b537dcbf738c3cb488af5ab0d (diff) | |
download | cpython-8dc226fccd2183670ac19a85b89941f5b05167dc.zip cpython-8dc226fccd2183670ac19a85b89941f5b05167dc.tar.gz cpython-8dc226fccd2183670ac19a85b89941f5b05167dc.tar.bz2 |
Merged revisions 62774-62775,62785,62787-62788 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62774 | georg.brandl | 2008-05-06 19:11:42 +0200 (Tue, 06 May 2008) | 2 lines
#2773: fix description of 'g' and 'G' formatting spec.
........
r62775 | georg.brandl | 2008-05-06 19:20:54 +0200 (Tue, 06 May 2008) | 2 lines
> != (!<).
........
r62785 | benjamin.peterson | 2008-05-07 00:18:11 +0200 (Wed, 07 May 2008) | 2 lines
Fix logic error in Python/_warnings.c and add a test to verify
........
r62787 | benjamin.peterson | 2008-05-07 00:31:52 +0200 (Wed, 07 May 2008) | 2 lines
Make the Python implementation of warnings compatible with the C implementation regarding non-callable showwarning
........
r62788 | christian.heimes | 2008-05-07 00:41:46 +0200 (Wed, 07 May 2008) | 1 line
Implemented PEP 370
........
Diffstat (limited to 'Lib/test/test_site.py')
-rw-r--r-- | Lib/test/test_site.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index b80d6e6..329df4b 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -10,6 +10,7 @@ import builtins import os import sys import encodings +import subprocess # 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. @@ -18,6 +19,11 @@ if "site" in sys.modules: else: raise TestSkipped("importation of site.py suppressed") +if not os.path.isdir(site.USER_SITE): + # need to add user site directory for tests + os.makedirs(site.USER_SITE) + site.addsitedir(site.USER_SITE) + class HelperFunctionsTests(unittest.TestCase): """Tests for helper functions. @@ -30,7 +36,7 @@ class HelperFunctionsTests(unittest.TestCase): """Save a copy of sys.path""" self.sys_path = sys.path[:] - def tearDown(self): + """Restore sys.path""" sys.path = self.sys_path @@ -90,6 +96,33 @@ class HelperFunctionsTests(unittest.TestCase): finally: pth_file.cleanup() + def test_s_option(self): + usersite = site.USER_SITE + self.assert_(usersite in sys.path) + + rc = subprocess.call([sys.executable, '-c', + 'import sys; sys.exit("%s" in sys.path)' % usersite]) + self.assertEqual(rc, 1) + + rc = subprocess.call([sys.executable, '-s', '-c', + 'import sys; sys.exit("%s" in sys.path)' % usersite]) + self.assertEqual(rc, 0) + + env = os.environ.copy() + env["PYTHONNOUSERSITE"] = "1" + rc = subprocess.call([sys.executable, '-c', + 'import sys; sys.exit("%s" in sys.path)' % usersite], + env=env) + self.assertEqual(rc, 0) + + env = os.environ.copy() + env["PYTHONUSERBASE"] = "/tmp" + rc = subprocess.call([sys.executable, '-c', + 'import sys, site; sys.exit(site.USER_BASE.startswith("/tmp"))'], + env=env) + self.assertEqual(rc, 1) + + class PthFile(object): """Helper class for handling testing of .pth files""" |