summaryrefslogtreecommitdiff
path: root/tests/brain/test_argparse.py
blob: 20d96e2ddb0d8bdbddf1889a3907a8ee23593f02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt

from astroid import bases, extract_node, nodes


class TestBrainArgparse:
    @staticmethod
    def test_infer_namespace() -> None:
        func = extract_node(
            """
        import argparse
        def make_namespace():  #@
            return argparse.Namespace(debug=True)
        """
        )
        assert isinstance(func, nodes.FunctionDef)
        inferred = next(func.infer_call_result(func))
        assert isinstance(inferred, bases.Instance)
        assert not func.locals