Debian Codegraph @

tests/test_coverup_123.py

raw symbols SCIP
1 # file scalene/scalene_profiler.py:1833-1841
2 # lines [1836, 1837, 1838, 1839, 1840, 1841]
3 # branches []
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 # Mocking the ScaleneParseArgs.parse_args method to return specific arguments
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 # Mocking the Scalene.set_initialized and Scalene.run_profiler methods
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 # Test function to cover lines 1836-1841
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(), [])