diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2023-10-14 21:32:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-14 21:32:57 (GMT) |
commit | 84b7e9e3fa67fb9b92088d17839d8235f1cec62e (patch) | |
tree | 662ceaa5e4c9c4fd12695756ef3d0d199f85701d /Lib/test/test_embed.py | |
parent | ab08ff7882b6181fb785eed7410dbf8030aded70 (diff) | |
download | cpython-84b7e9e3fa67fb9b92088d17839d8235f1cec62e.zip cpython-84b7e9e3fa67fb9b92088d17839d8235f1cec62e.tar.gz cpython-84b7e9e3fa67fb9b92088d17839d8235f1cec62e.tar.bz2 |
gh-110722: Add PYTHON_PRESITE to import a module before site.py is run (#110769)
Diffstat (limited to 'Lib/test/test_embed.py')
-rw-r--r-- | Lib/test/test_embed.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py index 5a8690a..d2d6c1b 100644 --- a/Lib/test/test_embed.py +++ b/Lib/test/test_embed.py @@ -515,6 +515,8 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase): } if Py_STATS: CONFIG_COMPAT['_pystats'] = 0 + if support.Py_DEBUG: + CONFIG_COMPAT['run_presite'] = None if MS_WINDOWS: CONFIG_COMPAT.update({ 'legacy_windows_stdio': 0, @@ -1818,6 +1820,22 @@ class MiscTests(EmbeddingTestsMixin, unittest.TestCase): self.assertEqual(refs, 0, out) self.assertEqual(blocks, 0, out) + @unittest.skipUnless(support.Py_DEBUG, + '-X presite requires a Python debug build') + def test_presite(self): + cmd = [sys.executable, "-I", "-X", "presite=test.reperf", "-c", "print('cmd')"] + proc = subprocess.run( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + text=True, + ) + self.assertEqual(proc.returncode, 0) + out = proc.stdout.strip() + self.assertIn("10 times sub", out) + self.assertIn("CPU seconds", out) + self.assertIn("cmd", out) + class StdPrinterTests(EmbeddingTestsMixin, unittest.TestCase): # Test PyStdPrinter_Type which is used by _PySys_SetPreliminaryStderr(): |