Debian Codegraph @

tests/test_coverup_8.py

raw symbols SCIP
1 # file scalene/scalene_analysis.py:44-67
2 # lines [44, 45, 57, 58, 59, 62, 64, 65, 67]
3 # branches ['62->64', '62->67', '64->62', '64->65']
4
5 import pytest
6 from scalene.scalene_analysis import ScaleneAnalysis
7 import ast
8
9
10 @pytest.fixture
11 def cleanup_imports():
12 # Fixture to clean up any added imports after the test
13 yield
14 # No cleanup needed as the test does not modify any state
15
16
17 def test_get_imported_modules(cleanup_imports):
18 source_code = """
19 import os
20 import sys as system
21 from collections import defaultdict
22 """
23 expected_imports = [
24 "import os",
25 "import sys as system",
26 "from collections import defaultdict",
27 ]
28 imported_modules = ScaleneAnalysis.get_imported_modules(source_code)
29 assert set(imported_modules) == set(
30 expected_imports
31 ), "The imported modules do not match the expected imports"