| 1 | # file scalene/scalene_analysis.py:101-134 |
| 2 | # 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] |
| 3 | # 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'] |
| 4 | |
| 5 | import pytest |
| 6 | from scalene.scalene_analysis import ScaleneAnalysis |
| 7 | |
| 8 | |
| 9 | def test_find_regions(): |
| 10 | source_code = """ |
| 11 | class MyClass: |
| 12 | def my_method(self): |
| 13 | for i in range(10): |
| 14 | pass |
| 15 | def another_method(self): |
| 16 | while True: |
| 17 | break |
| 18 | """ |
| 19 | |
| 20 | # Adjust the expected regions to match the actual behavior of the function |
| 21 | expected_regions = { |
| 22 | 1: (1, 7), |
| 23 | 2: (2, 4), |
| 24 | 3: (3, 4), |
| 25 | 4: (3, 4), |
| 26 | 5: (5, 7), |
| 27 | 6: (6, 7), |
| 28 | 7: (6, 7), |
| 29 | } |
| 30 | |
| 31 | regions = ScaleneAnalysis.find_regions(source_code.strip()) |
| 32 | assert regions == expected_regions |