|
6 | 6 | 3. Stack traversal: _build_linear_stacks() with BFS |
7 | 7 | """ |
8 | 8 |
|
| 9 | +import inspect |
9 | 10 | import unittest |
10 | 11 |
|
11 | 12 | try: |
12 | 13 | import _remote_debugging # noqa: F401 |
13 | 14 | from profiling.sampling.pstats_collector import PstatsCollector |
| 15 | + from profiling.sampling.stack_collector import FlamegraphCollector |
| 16 | + from profiling.sampling.sample import sample, sample_live, SampleProfiler |
14 | 17 | except ImportError: |
15 | 18 | raise unittest.SkipTest( |
16 | 19 | "Test only runs when _remote_debugging is available" |
@@ -561,8 +564,6 @@ class TestFlamegraphCollectorAsync(unittest.TestCase): |
561 | 564 |
|
562 | 565 | def test_flamegraph_with_async_frames(self): |
563 | 566 | """Test FlamegraphCollector correctly processes async task frames.""" |
564 | | - from profiling.sampling.stack_collector import FlamegraphCollector |
565 | | - |
566 | 567 | collector = FlamegraphCollector(sample_interval_usec=1000) |
567 | 568 |
|
568 | 569 | # Build async task tree: Root -> Child |
@@ -607,8 +608,6 @@ def test_flamegraph_with_async_frames(self): |
607 | 608 |
|
608 | 609 | def test_flamegraph_with_task_markers(self): |
609 | 610 | """Test FlamegraphCollector includes <task> boundary markers.""" |
610 | | - from profiling.sampling.stack_collector import FlamegraphCollector |
611 | | - |
612 | 611 | collector = FlamegraphCollector(sample_interval_usec=1000) |
613 | 612 |
|
614 | 613 | task = MockTaskInfo( |
@@ -643,8 +642,6 @@ def find_task_marker(node, depth=0): |
643 | 642 |
|
644 | 643 | def test_flamegraph_multiple_async_samples(self): |
645 | 644 | """Test FlamegraphCollector aggregates multiple async samples correctly.""" |
646 | | - from profiling.sampling.stack_collector import FlamegraphCollector |
647 | | - |
648 | 645 | collector = FlamegraphCollector(sample_interval_usec=1000) |
649 | 646 |
|
650 | 647 | task = MockTaskInfo( |
@@ -675,25 +672,16 @@ class TestAsyncAwareParameterFlow(unittest.TestCase): |
675 | 672 |
|
676 | 673 | def test_sample_function_accepts_async_aware(self): |
677 | 674 | """Test that sample() function accepts async_aware parameter.""" |
678 | | - from profiling.sampling.sample import sample |
679 | | - import inspect |
680 | | - |
681 | 675 | sig = inspect.signature(sample) |
682 | 676 | self.assertIn("async_aware", sig.parameters) |
683 | 677 |
|
684 | 678 | def test_sample_live_function_accepts_async_aware(self): |
685 | 679 | """Test that sample_live() function accepts async_aware parameter.""" |
686 | | - from profiling.sampling.sample import sample_live |
687 | | - import inspect |
688 | | - |
689 | 680 | sig = inspect.signature(sample_live) |
690 | 681 | self.assertIn("async_aware", sig.parameters) |
691 | 682 |
|
692 | 683 | def test_sample_profiler_sample_accepts_async_aware(self): |
693 | 684 | """Test that SampleProfiler.sample() accepts async_aware parameter.""" |
694 | | - from profiling.sampling.sample import SampleProfiler |
695 | | - import inspect |
696 | | - |
697 | 685 | sig = inspect.signature(SampleProfiler.sample) |
698 | 686 | self.assertIn("async_aware", sig.parameters) |
699 | 687 |
|
|
0 commit comments