File: test_coverup_123.py

package info (click to toggle)
scalene 1.5.51-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,528 kB
  • sloc: cpp: 22,930; python: 13,403; javascript: 11,769; ansic: 817; makefile: 196; sh: 45
file content (29 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download
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(), [])