File: test_coverup_78.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 (30 lines) | stat: -rw-r--r-- 1,122 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
30
# file scalene/scalene_profiler.py:1843-1854
# lines [1843, 1844, 1846, 1848, 1850, 1851, 1852, 1853]
# branches []

import pytest
from unittest.mock import patch
from scalene.scalene_profiler import Scalene

@pytest.fixture
def scalene_cleanup():
    # Fixture to clean up any state after the test
    yield
    Scalene._Scalene__files_to_profile.clear()

def test_register_files_to_profile(scalene_cleanup):
    # Set up the necessary attributes in Scalene
    Scalene._Scalene__args = type('', (), {})()
    Scalene._Scalene__args.profile_only = 'test1.py,test2.py'
    Scalene._Scalene__args.profile_all = False
    Scalene._Scalene__files_to_profile = set(['test3.py'])
    Scalene._Scalene__program_path = '.'

    with patch('scalene.pywhere.register_files_to_profile') as mock_register_files_to_profile:
        # Call the method under test
        Scalene.register_files_to_profile()

        # Check that pywhere.register_files_to_profile was called with the correct arguments
        mock_register_files_to_profile.assert_called_once_with(
            ['test3.py', 'test1.py', 'test2.py'], '.', False
        )