Esempio n. 1
0
    def test_parse_unused_args(self) -> None:
        # pylint: disable=pointless-statement,unused-argument
        def test_function(x):
            1

        # pylint: enable=pointless-statement,unused-argument
        with self.assertRaisesRegex(
                function_parser.UnusedArgument,
                r'Unused argument "x" in function test_function:\d+',
        ):
            function_parser.parse(test_function)
Esempio n. 2
0
    def test_parse_single_line(self) -> None:
        # pylint: disable=pointless-statement
        def test_function(x):
            x

        # pylint: enable=pointless-statement
        self.assert_node_equal(
            function_parser.parse(test_function)[0], libcst.Name("x"))
Esempio n. 3
0
    def test_parse_without_docstring(self) -> None:
        # pylint: disable=pointless-statement
        def test_function():
            1

        # pylint: enable=pointless-statement
        self.assert_node_equal(
            function_parser.parse(test_function)[0], libcst.Integer("1"))
Esempio n. 4
0
    def test_parse_semicolon(self) -> None:
        # fmt: off
        # pylint: disable=pointless-statement,unnecessary-semicolon
        def test_function(x):
            x

        # fmt: on
        # pylint: enable=pointless-statement,unnecessary-semicolon
        self.assert_node_equal(
            function_parser.parse(test_function)[0], libcst.Name("x"))
Esempio n. 5
0
    def test_parse_multiple_statements(self) -> None:
        # pylint: disable=pointless-statement
        def test_function(x, y):
            x
            y

        # pylint: enable=pointless-statement
        self.assert_node_equal(
            function_parser.parse(test_function)[0],
            libcst.SimpleStatementLine(body=[libcst.Expr(libcst.Name("x"))]),
        )