File: test_coverup_8.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 (27 lines) | stat: -rw-r--r-- 849 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
# file scalene/scalene_analysis.py:44-67
# lines [44, 45, 57, 58, 59, 62, 64, 65, 67]
# branches ['62->64', '62->67', '64->62', '64->65']

import pytest
from scalene.scalene_analysis import ScaleneAnalysis
import ast

@pytest.fixture
def cleanup_imports():
    # Fixture to clean up any added imports after the test
    yield
    # No cleanup needed as the test does not modify any state

def test_get_imported_modules(cleanup_imports):
    source_code = """
import os
import sys as system
from collections import defaultdict
"""
    expected_imports = [
        "import os",
        "import sys as system",
        "from collections import defaultdict"
    ]
    imported_modules = ScaleneAnalysis.get_imported_modules(source_code)
    assert set(imported_modules) == set(expected_imports), "The imported modules do not match the expected imports"