File: test_coverup_16.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 (31 lines) | stat: -rw-r--r-- 1,094 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
31
# file scalene/scalene_analysis.py:101-134
# lines [105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 133, 134]
# branches ['112->113', '112->125', '113->114', '113->117', '115->116', '115->117', '117->118', '117->121', '119->120', '119->121', '121->112', '121->122', '123->112', '123->124', '125->126', '125->134', '126->127', '126->128', '128->129', '128->130', '130->131', '130->133']

import pytest
from scalene.scalene_analysis import ScaleneAnalysis

def test_find_regions():
    source_code = """
class MyClass:
    def my_method(self):
        for i in range(10):
            pass
    def another_method(self):
        while True:
            break
"""

    # Adjust the expected regions to match the actual behavior of the function
    expected_regions = {
        1: (1, 7),
        2: (2, 4),
        3: (3, 4),
        4: (3, 4),
        5: (5, 7),
        6: (6, 7),
        7: (6, 7),
    }

    regions = ScaleneAnalysis.find_regions(source_code.strip())
    assert regions == expected_regions