| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import pytest |
| 6 |
from scalene.scalene_profiler import Scalene |
| 7 |
from scalene.scalene_arguments import ScaleneArguments |
| 8 |
from unittest.mock import patch |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
@pytest.fixture |
| 13 |
def mock_parse_args(): |
| 14 |
with patch("scalene.scalene_profiler.ScaleneParseArgs.parse_args") as mock: |
| 15 |
mock.return_value = (ScaleneArguments(), []) |
| 16 |
yield mock |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
@pytest.fixture |
| 21 |
def mock_scalene_methods(): |
| 22 |
with patch( |
| 23 |
"scalene.scalene_profiler.Scalene.set_initialized" |
| 24 |
) as mock_initialized, patch( |
| 25 |
"scalene.scalene_profiler.Scalene.run_profiler" |
| 26 |
) as mock_run_profiler: |
| 27 |
yield mock_initialized, mock_run_profiler |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
def test_main_execution(mock_parse_args, mock_scalene_methods): |
| 32 |
Scalene.main() |
| 33 |
mock_parse_args.assert_called_once() |
| 34 |
mock_scalene_methods[0].assert_called_once() |
| 35 |
mock_scalene_methods[1].assert_called_once_with(ScaleneArguments(), []) |