diff options
Diffstat (limited to 'Lib/test/test_site.py')
-rw-r--r-- | Lib/test/test_site.py | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index f3bd168168..83252227ec 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -230,11 +230,7 @@ class HelperFunctionsTests(unittest.TestCase): site.PREFIXES = ['xoxo'] dirs = site.getsitepackages() - if sys.platform in ('os2emx', 'riscos'): - self.assertEqual(len(dirs), 1) - wanted = os.path.join('xoxo', 'Lib', 'site-packages') - self.assertEqual(dirs[0], wanted) - elif (sys.platform == "darwin" and + if (sys.platform == "darwin" and sysconfig.get_config_var("PYTHONFRAMEWORK")): # OS X framework builds site.PREFIXES = ['Python.framework'] @@ -418,6 +414,8 @@ class ImportSideEffectTests(unittest.TestCase): @test.support.requires_resource('network') @unittest.skipUnless(sys.version_info[3] == 'final', 'only for released versions') + @unittest.skipUnless(hasattr(urllib.request, "HTTPSHandler"), + 'need SSL support to download license') def test_license_exists_at_url(self): # This test is a bit fragile since it depends on the format of the # string displayed by license in the absence of a LICENSE file. @@ -432,5 +430,39 @@ class ImportSideEffectTests(unittest.TestCase): self.assertEqual(code, 200, msg="Can't find " + url) +class StartupImportTests(unittest.TestCase): + + def test_startup_imports(self): + # This tests checks which modules are loaded by Python when it + # initially starts upon startup. + popen = subprocess.Popen([sys.executable, '-I', '-v', '-c', + 'import sys; print(set(sys.modules))'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = popen.communicate() + stdout = stdout.decode('utf-8') + stderr = stderr.decode('utf-8') + modules = eval(stdout) + + self.assertIn('site', modules) + + # http://bugs.python.org/issue19205 + re_mods = {'re', '_sre', 'sre_compile', 'sre_constants', 'sre_parse'} + # _osx_support uses the re module in many placs + if sys.platform != 'darwin': + self.assertFalse(modules.intersection(re_mods), stderr) + # http://bugs.python.org/issue9548 + self.assertNotIn('locale', modules, stderr) + if sys.platform != 'darwin': + # http://bugs.python.org/issue19209 + self.assertNotIn('copyreg', modules, stderr) + # http://bugs.python.org/issue19218> + collection_mods = {'_collections', 'collections', 'functools', + 'heapq', 'itertools', 'keyword', 'operator', + 'reprlib', 'types', 'weakref' + }.difference(sys.builtin_module_names) + self.assertFalse(modules.intersection(collection_mods), stderr) + + if __name__ == "__main__": unittest.main() |