diff -r b0c4c7f04f05 Lib/test/test_site.py --- a/Lib/test/test_site.py Sun Dec 01 13:23:48 2013 +0100 +++ b/Lib/test/test_site.py Sun Dec 01 22:24:28 2013 +0800 @@ -25,13 +25,17 @@ if "site" in sys.modules: import site else: - raise unittest.SkipTest("importation of site.py suppressed") + site = None -if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE): +if (site is not None and + site.ENABLE_USER_SITE and + 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) + +@unittest.skipUnless(site, "importation of site.py suppressed") class HelperFunctionsTests(unittest.TestCase): """Tests for helper functions. """ @@ -163,8 +167,9 @@ finally: pth_file.cleanup() - @unittest.skipUnless(site.ENABLE_USER_SITE, "requires access to PEP 370 " - "user-site (site.ENABLE_USER_SITE)") + @unittest.skipUnless(site is not None and site.ENABLE_USER_SITE, + "requires access to PEP 370 user-site " + "(site.ENABLE_USER_SITE)") def test_s_option(self): usersite = site.USER_SITE self.assertIn(usersite, sys.path) @@ -257,6 +262,7 @@ wanted = os.path.join('xoxo', 'lib', 'site-packages') self.assertEqual(dirs[1], wanted) + class PthFile(object): """Helper class for handling testing of .pth files""" @@ -312,6 +318,8 @@ if os.path.exists(self.bad_dir_path): os.rmdir(self.bad_dir_path) + +@unittest.skipUnless(site, "importation of site.py suppressed") class ImportSideEffectTests(unittest.TestCase): """Test side-effects from importing 'site'.""" @@ -428,6 +436,7 @@ self.assertEqual(code, 200, msg="Can't find " + url) +@unittest.skipUnless(site, "importation of site.py suppressed") class StartupImportTests(unittest.TestCase): def test_startup_imports(self):