https://github.com/python/cpython/commit/cb6fed0d7e3f5104b76ef2febc51f11a94aa2e04
commit: cb6fed0d7e3f5104b76ef2febc51f11a94aa2e04
branch: main
author: Pablo Galindo Salgado <[email protected]>
committer: pablogsal <[email protected]>
date: 2025-09-21T18:39:07Z
summary:

gh-138709: Supress stdout/stderr during test_sampling_profiler tests (#139212)

files:
M Lib/test/test_profiling/test_sampling_profiler.py

diff --git a/Lib/test/test_profiling/test_sampling_profiler.py 
b/Lib/test/test_profiling/test_sampling_profiler.py
index fd6b1862230288..687dd733807db7 100644
--- a/Lib/test/test_profiling/test_sampling_profiler.py
+++ b/Lib/test/test_profiling/test_sampling_profiler.py
@@ -22,6 +22,7 @@
 from test.support import force_not_colorized_test_class, SHORT_TIMEOUT
 from test.support.socket_helper import find_unused_port
 from test.support import requires_subprocess, is_emscripten
+from test.support import captured_stdout, captured_stderr
 
 PROCESS_VM_READV_SUPPORTED = False
 
@@ -416,7 +417,8 @@ def test_collapsed_stack_collector_export(self):
         collector.collect(test_frames2)
         collector.collect(test_frames3)
 
-        collector.export(collapsed_out.name)
+        with (captured_stdout(), captured_stderr()):
+            collector.export(collapsed_out.name)
         # Check file contents
         with open(collapsed_out.name, "r") as f:
             content = f.read()
@@ -500,7 +502,8 @@ def test_flamegraph_collector_export(self):
         collector.collect(test_frames3)
 
         # Export flamegraph
-        collector.export(flamegraph_out.name)
+        with (captured_stdout(), captured_stderr()):
+            collector.export(flamegraph_out.name)
 
         # Verify file was created and contains valid data
         self.assertTrue(os.path.exists(flamegraph_out.name))
@@ -1918,7 +1921,7 @@ def test_valid_output_formats(self):
         self.addCleanup(shutil.rmtree, tempdir.name)
 
 
-        with contextlib.chdir(tempdir.name):
+        with (contextlib.chdir(tempdir.name), captured_stdout(), 
captured_stderr()):
             for fmt in valid_formats:
                 try:
                     # This will likely fail with permissions, but the format 
should be valid
@@ -2632,6 +2635,7 @@ def test_gil_mode_collector_configuration(self):
         with (
             mock.patch("profiling.sampling.sample.SampleProfiler") as 
mock_profiler,
             mock.patch("profiling.sampling.sample.PstatsCollector") as 
mock_collector,
+            captured_stdout(), captured_stderr()
         ):
             # Mock the profiler instance
             mock_instance = mock.Mock()

_______________________________________________
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]

Reply via email to