Skip to content

Commit

Permalink
Add validation test for If node
Browse files Browse the repository at this point in the history
  • Loading branch information
kiri11 committed Jul 30, 2024
1 parent e9a5aa8 commit bc81aea
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion libcst/_nodes/tests/test_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import Any
from typing import Any, Callable

import libcst as cst
from libcst import parse_statement
Expand Down Expand Up @@ -129,3 +129,21 @@ class IfTest(CSTNodeTest):
)
def test_valid(self, **kwargs: Any) -> None:
self.validate_node(**kwargs)

@data_provider(
(
# Validate whitespace handling
(
lambda: cst.If(
cst.Name("conditional"),
cst.SimpleStatementSuite((cst.Pass(),)),
whitespace_before_test=cst.SimpleWhitespace("")
),
"Must have at least one space after 'if' keyword.",
),
)
)
def test_invalid(
self, get_node: Callable[[], cst.CSTNode], expected_re: str
) -> None:
self.assert_invalid(get_node, expected_re)

0 comments on commit bc81aea

Please sign in to comment.