1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
# file scalene/scalene_profiler.py:1833-1841
# lines [1836, 1837, 1838, 1839, 1840, 1841]
# branches []
import pytest
from scalene.scalene_profiler import Scalene
from scalene.scalene_arguments import ScaleneArguments
from unittest.mock import patch
# Mocking the ScaleneParseArgs.parse_args method to return specific arguments
@pytest.fixture
def mock_parse_args():
with patch('scalene.scalene_profiler.ScaleneParseArgs.parse_args') as mock:
mock.return_value = (ScaleneArguments(), [])
yield mock
# Mocking the Scalene.set_initialized and Scalene.run_profiler methods
@pytest.fixture
def mock_scalene_methods():
with patch('scalene.scalene_profiler.Scalene.set_initialized') as mock_initialized, \
patch('scalene.scalene_profiler.Scalene.run_profiler') as mock_run_profiler:
yield mock_initialized, mock_run_profiler
# Test function to cover lines 1836-1841
def test_main_execution(mock_parse_args, mock_scalene_methods):
Scalene.main()
mock_parse_args.assert_called_once()
mock_scalene_methods[0].assert_called_once()
mock_scalene_methods[1].assert_called_once_with(ScaleneArguments(), [])
|