| 1 | # file scalene/scalene_profiler.py:879-893 |
| 2 | # lines [884] |
| 3 | # branches ['883->884'] |
| 4 | |
| 5 | import pytest |
| 6 | from scalene.scalene_profiler import Scalene |
| 7 | |
| 8 | |
| 9 | @pytest.fixture |
| 10 | def scalene_cleanup(): |
| 11 | # Store original state |
| 12 | original_files_to_profile = Scalene._Scalene__files_to_profile.copy() |
| 13 | yield |
| 14 | # Restore original state after test |
| 15 | Scalene._Scalene__files_to_profile = original_files_to_profile |
| 16 | |
| 17 | |
| 18 | def test_profile_this_code_without_files_to_profile(scalene_cleanup): |
| 19 | # Ensure __files_to_profile is empty |
| 20 | Scalene._Scalene__files_to_profile.clear() |
| 21 | # Call the method with arbitrary arguments |
| 22 | result = Scalene.profile_this_code("somefile.py", 10) |
| 23 | # Assert that the result is True when __files_to_profile is empty |
| 24 | assert result == True |