Debian Codegraph @

tests/test_stdlib.py

raw
1 # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
2 # For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
3 # Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
4
5 """Tests for modules in the stdlib."""
6
7 from astroid import nodes
8 from astroid.builder import _extract_single_node
9
10
11 class TestSys:
12 """Tests for the sys module."""
13
14 def test_sys_builtin_module_names(self) -> None:
15 """Test that we can gather the elements of a living tuple object."""
16 node = _extract_single_node("""
17 import sys
18 sys.builtin_module_names
19 """)
20 inferred = list(node.infer())
21 assert len(inferred) == 1
22 assert isinstance(inferred[0], nodes.Tuple)
23 assert inferred[0].elts
24
25 def test_sys_modules(self) -> None:
26 """Test that we can gather the items of a living dict object."""
27 node = _extract_single_node("""
28 import sys
29 sys.modules
30 """)
31 inferred = list(node.infer())
32 assert len(inferred) == 1
33 assert isinstance(inferred[0], nodes.Dict)
34 assert inferred[0].items