Debian Codegraph @

tests/test_coverup_133.py

raw symbols SCIP
1 # file scalene/scalene_profiler.py:868-877
2 # lines [873, 874, 875, 877]
3 # branches []
4
5 import pytest
6 from scalene.scalene_profiler import Scalene
7 from types import FunctionType
8
9
10 # Create a dummy function to profile
11 def dummy_function():
12 pass
13
14
15 # Add the dummy function to the __functions_to_profile dictionary
16 Scalene._Scalene__functions_to_profile = {"dummy_file.py": [dummy_function]}
17
18
19 @pytest.fixture
20 def cleanup_scalene():
21 # Fixture to clean up changes made to the Scalene class
22 yield
23 # Remove the dummy function from the __functions_to_profile dictionary
24 Scalene._Scalene__functions_to_profile.pop("dummy_file.py", None)
25
26
27 def test_get_line_info(cleanup_scalene):
28 # Test the get_line_info method to ensure it covers the missing lines
29 line_info_list = Scalene.get_line_info("dummy_file.py")
30 line_info = line_info_list[0]
31 assert isinstance(line_info, tuple)
32 assert isinstance(line_info[0], list)
33 assert isinstance(line_info[1], int)
34 # The line number where dummy_function is defined might not be 1
35 # So we check if the first line of the source code is the definition of dummy_function
36 assert line_info[0][0].strip() == "def dummy_function():"