Debian Codegraph @

tests/brain/test_argparse.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 from astroid import bases, extract_node, nodes
6
7
8 class TestBrainArgparse:
9 @staticmethod
10 def test_infer_namespace() -> None:
11 func = extract_node("""
12 import argparse
13 def make_namespace(): #@
14 return argparse.Namespace(debug=True)
15 """)
16 assert isinstance(func, nodes.FunctionDef)
17 inferred = next(func.infer_call_result(func))
18 assert isinstance(inferred, bases.Instance)
19 assert not func.locals