From 0ab447192e5490f73b5edbc3900a9cae86bcdb99 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Mon, 19 May 2025 15:26:28 -0500 Subject: [PATCH] test that generated code displays source code in profile --- tests/test_line_profiler.py | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/test_line_profiler.py b/tests/test_line_profiler.py index 85860b2a..46322dbc 100644 --- a/tests/test_line_profiler.py +++ b/tests/test_line_profiler.py @@ -578,3 +578,48 @@ def test_sys_monitoring(): assert tool is None, ( f'Expected no active profiling tool after profiling, got {tool!r}' ) + + +def test_profile_generated_code(): + """ + Test that profiling shows source information with generated code. + """ + import linecache + from line_profiler import LineProfiler + from line_profiler.line_profiler import is_generated_code + + # Simulate generated code in linecache + + # Note: this test will fail if the generated code name does not + # start with "