Skip to content

Commit a019e6a

Browse files
committed
fixup! Add tests for sampling profiler
1 parent bf9e3fa commit a019e6a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Lib/test/test_sample_profiler.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919

2020
from test.support.os_helper import unlink
2121

22+
PROCESS_VM_READV_SUPPORTED = False
23+
24+
try:
25+
from _remote_debugging import PROCESS_VM_READV_SUPPORTED
26+
except ImportError:
27+
raise unittest.SkipTest(
28+
"Test only runs when _remote_debugging is available"
29+
)
30+
2231

2332
class MockFrameInfo:
2433
"""Mock FrameInfo for testing since the real one isn't accessible."""
@@ -256,11 +265,13 @@ def test_pstats_collector_export(self):
256265
self.assertEqual(func1_stats[3], 2.0) # ct (cumulative time)
257266

258267

268+
@unittest.skipIf(
269+
sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
270+
"Test only runs on Linux with process_vm_readv support",
271+
)
259272
class TestSampleProfilerIntegration(unittest.TestCase):
260273
@classmethod
261274
def setUpClass(cls):
262-
cls.python_exe = sys.executable
263-
264275
cls.test_script = '''
265276
import time
266277
import os
@@ -472,6 +483,10 @@ def test_sampling_all_threads(self):
472483
# We're not testing output format here
473484

474485

486+
@unittest.skipIf(
487+
sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED,
488+
"Test only runs on Linux with process_vm_readv support",
489+
)
475490
class TestSampleProfilerErrorHandling(unittest.TestCase):
476491
def test_invalid_pid(self):
477492
with self.assertRaises((OSError, RuntimeError)):

0 commit comments

Comments
 (0)