| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import pytest |
| 6 |
from unittest.mock import patch |
| 7 |
from scalene.scalene_profiler import Scalene |
| 8 |
|
| 9 |
|
| 10 |
@pytest.fixture |
| 11 |
def scalene_cleanup(): |
| 12 |
|
| 13 |
yield |
| 14 |
Scalene._Scalene__files_to_profile.clear() |
| 15 |
|
| 16 |
|
| 17 |
def test_register_files_to_profile(scalene_cleanup): |
| 18 |
|
| 19 |
Scalene._Scalene__args = type("", (), {})() |
| 20 |
Scalene._Scalene__args.profile_only = "test1.py,test2.py" |
| 21 |
Scalene._Scalene__args.profile_all = False |
| 22 |
Scalene._Scalene__files_to_profile = set(["test3.py"]) |
| 23 |
Scalene._Scalene__program_path = "." |
| 24 |
|
| 25 |
with patch( |
| 26 |
"scalene.pywhere.register_files_to_profile" |
| 27 |
) as mock_register_files_to_profile: |
| 28 |
|
| 29 |
Scalene.register_files_to_profile() |
| 30 |
|
| 31 |
|
| 32 |
mock_register_files_to_profile.assert_called_once_with( |
| 33 |
["test3.py", "test1.py", "test2.py"], ".", False |
| 34 |
) |