# file scalene/scalene_profiler.py:879-893 # lines [879, 880, 883, 884, 885, 886, 888, 889, 890, 891, 893] # branches ['883->884', '883->885', '885->886', '885->888'] import pytest from scalene.scalene_profiler import Scalene from scalene.scalene_arguments import ScaleneArguments # Mock filename and line number mock_filename = "mock_file.py" mock_lineno = 10 # Create a test function to execute the missing lines/branches def test_profile_this_code(monkeypatch): # Set up the test environment monkeypatch.setattr(Scalene, "_Scalene__files_to_profile", set()) Scalene._Scalene__files_to_profile.add(mock_filename) # Mock the get_line_info method def mock_get_line_info(filename): if filename == mock_filename: return [((mock_lineno, mock_lineno + 1), mock_lineno)] return [] monkeypatch.setattr(Scalene, "get_line_info", mock_get_line_info) # Test when the file is in the set and the line number is within the range assert Scalene.profile_this_code(mock_filename, mock_lineno) == True # Test when the file is in the set but the line number is not within the range assert Scalene.profile_this_code(mock_filename, mock_lineno + 100) == False # Test when the file is not in the set assert Scalene.profile_this_code("other_file.py", mock_lineno) == False # No need to clean up after the test since we used monkeypatch # Run the test def test_scalene_profiler(monkeypatch): test_profile_this_code(monkeypatch)