|
11 | 11 | import unittest
|
12 | 12 | from unittest import mock
|
13 | 13 |
|
14 |
| -import profile.sample |
15 | 14 | from profile.pstats_collector import PstatsCollector
|
16 | 15 | from profile.stack_collectors import (
|
17 | 16 | CollapsedStackCollector,
|
18 | 17 | )
|
19 | 18 |
|
20 | 19 | from test.support.os_helper import unlink
|
21 | 20 |
|
| 21 | +PROCESS_VM_READV_SUPPORTED = False |
| 22 | + |
| 23 | +try: |
| 24 | + from _remote_debugging import PROCESS_VM_READV_SUPPORTED |
| 25 | +except ImportError: |
| 26 | + raise unittest.SkipTest( |
| 27 | + "Test only runs when _remote_debugging is available" |
| 28 | + ) |
| 29 | +else: |
| 30 | + import profile.sample |
| 31 | + |
22 | 32 |
|
23 | 33 | class MockFrameInfo:
|
24 | 34 | """Mock FrameInfo for testing since the real one isn't accessible."""
|
@@ -256,11 +266,13 @@ def test_pstats_collector_export(self):
|
256 | 266 | self.assertEqual(func1_stats[3], 2.0) # ct (cumulative time)
|
257 | 267 |
|
258 | 268 |
|
| 269 | +@unittest.skipIf( |
| 270 | + sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED, |
| 271 | + "Test only runs on Linux with process_vm_readv support", |
| 272 | +) |
259 | 273 | class TestSampleProfilerIntegration(unittest.TestCase):
|
260 | 274 | @classmethod
|
261 | 275 | def setUpClass(cls):
|
262 |
| - cls.python_exe = sys.executable |
263 |
| - |
264 | 276 | cls.test_script = '''
|
265 | 277 | import time
|
266 | 278 | import os
|
@@ -472,6 +484,10 @@ def test_sampling_all_threads(self):
|
472 | 484 | # We're not testing output format here
|
473 | 485 |
|
474 | 486 |
|
| 487 | +@unittest.skipIf( |
| 488 | + sys.platform == "linux" and not PROCESS_VM_READV_SUPPORTED, |
| 489 | + "Test only runs on Linux with process_vm_readv support", |
| 490 | +) |
475 | 491 | class TestSampleProfilerErrorHandling(unittest.TestCase):
|
476 | 492 | def test_invalid_pid(self):
|
477 | 493 | with self.assertRaises((OSError, RuntimeError)):
|
|
0 commit comments