summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_site.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-10-11 22:24:55 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-10-11 22:24:55 (GMT)
commit8c9cd5a3d466487c54440a47c8c04959e736aae0 (patch)
tree020a0d5f7b3760b1fa92eed862f813344226a2ce /Lib/test/test_site.py
parentfd4722cacf4885c29d358b8de6718b51a8149fa3 (diff)
downloadcpython-8c9cd5a3d466487c54440a47c8c04959e736aae0.zip
cpython-8c9cd5a3d466487c54440a47c8c04959e736aae0.tar.gz
cpython-8c9cd5a3d466487c54440a47c8c04959e736aae0.tar.bz2
Issue #19205: Don't import the 're' module in site and sysconfig module to
to speed up interpreter start.
Diffstat (limited to 'Lib/test/test_site.py')
-rw-r--r--Lib/test/test_site.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 575d65b..41fa7b1 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -420,5 +420,20 @@ 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.
+ args = [sys.executable, '-I', '-c',
+ 'import sys; print(set(sys.modules))']
+ stdout = subprocess.check_output(args)
+ modules = eval(stdout.decode('utf-8'))
+ self.assertIn('site', modules)
+
+ re_mods = {'re', '_sre', 'sre_compile', 'sre_constants', 'sre_parse'}
+ self.assertFalse(modules.intersection(re_mods))
+
+
if __name__ == "__main__":
unittest.main()