Debian Codegraph @

tests/test_coverup_103.py

raw symbols SCIP
1 # file scalene/scalene_profiler.py:895-897
2 # lines [895, 896, 897]
3 # branches []
4
5 import pytest
6 from scalene.scalene_profiler import Scalene
7 from scalene.scalene_statistics import StackFrame, StackStats
8
9
10 # Create a fixture to setup the Scalene for testing
11 @pytest.fixture
12 def scalene_profiler():
13 # Setup code if necessary
14 yield Scalene
15 # Teardown code if necessary
16
17
18 def test_print_stacks(capsys, scalene_profiler):
19 # Create test stacks
20 stack1 = StackFrame("test_file1.py", "test_function1", 1)
21 stack2 = StackFrame("test_file2.py", "test_function2", 2)
22 stats1 = StackStats(1, 1.0, 0.5, 2)
23 stats2 = StackStats(2, 2.0, 1.0, 4)
24
25 # Set up test data
26 scalene_profiler._Scalene__stats.stacks = {(stack1,): stats1, (stack2,): stats2}
27
28 # Call the function
29 scalene_profiler.print_stacks()
30
31 # Capture the output
32 captured = capsys.readouterr()
33
34 # Verify the output contains the expected stack information
35 assert "test_file1.py" in captured.out
36 assert "test_function1" in captured.out
37 assert "test_file2.py" in captured.out
38 assert "test_function2" in captured.out