Skip to content

Commit 8dd662c

Browse files
committed
simplify the test
1 parent 43d2cae commit 8dd662c

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

Lib/test/test_profiling/test_sampling_profiler/test_binary_format.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -810,34 +810,31 @@ def test_invalid_file_path(self):
810810
with BinaryReader("/nonexistent/path/file.bin") as reader:
811811
reader.replay_samples(RawCollector())
812812

813-
def test_new_thread_empty_stack(self):
814-
"""Empty stack roundtrips cleanly."""
813+
def test_binary_collector_skips_samples_with_empty_stacks(self):
814+
"""BinaryCollector skips samples that contain empty stacks."""
815+
frame = make_frame("a.py", 1, "f")
815816
samples = [
816817
[
817818
make_interpreter(
818819
0, [make_thread(99, [], status=THREAD_STATUS_UNKNOWN)]
819820
)
820-
]
821-
]
822-
collector, count = self.roundtrip(samples)
823-
self.assertEqual(count, 1)
824-
self.assert_samples_equal(samples, collector)
825-
826-
def test_new_thread_empty_stack_then_frames(self):
827-
"""Empty stack interleaved with normal stacks roundtrips clearly."""
828-
samples = [
829-
[make_interpreter(0, [make_thread(1, [make_frame("a.py", 1, "f")])])],
830-
[make_interpreter(0, [make_thread(1, [make_frame("a.py", 1, "f")])])],
821+
],
831822
[
832823
make_interpreter(
833-
0, [make_thread(99, [], status=THREAD_STATUS_UNKNOWN)]
824+
0,
825+
[
826+
make_thread(1, [frame]),
827+
make_thread(99, [], status=THREAD_STATUS_UNKNOWN),
828+
],
834829
)
835830
],
836-
[make_interpreter(0, [make_thread(1, [make_frame("a.py", 1, "f")])])],
831+
[make_interpreter(0, [make_thread(1, [frame])])],
837832
]
838833
collector, count = self.roundtrip(samples)
839-
self.assertEqual(count, 4)
840-
self.assert_samples_equal(samples, collector)
834+
self.assertEqual(count, 1)
835+
self.assert_samples_equal(
836+
[[make_interpreter(0, [make_thread(1, [frame])])]], collector
837+
)
841838

842839
def test_writer_total_samples_after_finalize_matches_reader(self):
843840
"""BinaryWriter.total_samples after finalize() matches the reader's count."""

0 commit comments

Comments
 (0)