| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
import pytest |
| 6 |
from scalene.scalene_profiler import Scalene |
| 7 |
from types import FunctionType |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
def dummy_function(): |
| 12 |
pass |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
Scalene._Scalene__functions_to_profile = {"dummy_file.py": [dummy_function]} |
| 17 |
|
| 18 |
|
| 19 |
@pytest.fixture |
| 20 |
def cleanup_scalene(): |
| 21 |
|
| 22 |
yield |
| 23 |
|
| 24 |
Scalene._Scalene__functions_to_profile.pop("dummy_file.py", None) |
| 25 |
|
| 26 |
|
| 27 |
def test_get_line_info(cleanup_scalene): |
| 28 |
|
| 29 |
line_info_list = Scalene.get_line_info("dummy_file.py") |
| 30 |
line_info = line_info_list[0] |
| 31 |
assert isinstance(line_info, tuple) |
| 32 |
assert isinstance(line_info[0], list) |
| 33 |
assert isinstance(line_info[1], int) |
| 34 |
|
| 35 |
|
| 36 |
assert line_info[0][0].strip() == "def dummy_function():" |