File: test_argparse.py

package info (click to toggle)
astroid 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,132 kB
  • sloc: python: 38,560; makefile: 24
file content (21 lines) | stat: -rw-r--r-- 734 bytes parent folder | download | duplicates (2)
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