https://github.com/python/cpython/commit/cb912e108c590bb0b8ded55653e63ad47f945362 commit: cb912e108c590bb0b8ded55653e63ad47f945362 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: vstinner <[email protected]> date: 2026-07-10T02:49:38Z summary:
[3.15] gh-121608: Fix test_samply_profiler: only check samply once (GH-153424) (#153457) gh-121608: Fix test_samply_profiler: only check samply once (GH-153424) Only run samply_command_works() once. Remove also dead code. (cherry picked from commit 311444998140240c164092640897013500b05963) Co-authored-by: Victor Stinner <[email protected]> files: M Lib/test/test_samply_profiler.py diff --git a/Lib/test/test_samply_profiler.py b/Lib/test/test_samply_profiler.py index f9ab9207c3c23d..6c3be8f38ed0c0 100644 --- a/Lib/test/test_samply_profiler.py +++ b/Lib/test/test_samply_profiler.py @@ -31,12 +31,7 @@ def supports_trampoline_profiling(): raise unittest.SkipTest("perf trampoline profiling not supported") -def samply_command_works(): - try: - cmd = ["samply", "--help"] - except (subprocess.SubprocessError, OSError): - return False - +def _samply_command_works(): # Check that we can run a simple samply run with temp_dir() as script_dir: try: @@ -90,8 +85,10 @@ def run_samply(cwd, *args, **env_vars): with gzip.open(output_file, mode="rt", encoding="utf-8") as f: return f.read() +SAMPLY_COMMAND_WORKS = _samply_command_works() + [email protected](samply_command_works(), "samply command doesn't work") [email protected](SAMPLY_COMMAND_WORKS, "samply command doesn't work") class TestSamplyProfilerMixin: def run_samply(self, script_dir, perf_mode, script): raise NotImplementedError() @@ -145,7 +142,7 @@ def baz(n): self.assertNotIn(f"py::baz:{script}", output) [email protected](samply_command_works(), "samply command doesn't work") [email protected](SAMPLY_COMMAND_WORKS, "samply command doesn't work") class TestSamplyProfiler(unittest.TestCase, TestSamplyProfilerMixin): def run_samply(self, script_dir, script, activate_trampoline=True): if activate_trampoline: @@ -240,7 +237,7 @@ def compile_trampolines_for_all_functions(): self.assertIn(line, child_perf_file_contents) [email protected](samply_command_works(), "samply command doesn't work") [email protected](SAMPLY_COMMAND_WORKS, "samply command doesn't work") class TestSamplyProfilerWithJitDump(unittest.TestCase, TestSamplyProfilerMixin): # Regression test for gh-150723: exercises the binary jitdump backend # (-Xperf_jit) end to end through samply, unlike TestSamplyProfiler which _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
