Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@ jobs:
run: uv sync --locked --dev
- name: Native Parser Tests
run: uv run poe test
- name: Pure Parser Tests
env:
COVERAGE_FILE: .coverage.pure
LIBCST_PARSER_TYPE: pure
run: uv run poe test
- name: Coverage
run: |
uv run coverage combine .coverage.pure
uv run coverage report
run: uv run coverage report

# Run linters
lint:
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -1184,7 +1183,7 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)

Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_binary_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -189,4 +188,4 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_parse_error(self, **kwargs: Any) -> None:
self.assert_parses(**kwargs, expect_success=not is_native())
self.assert_parses(**kwargs, expect_success=False)
3 changes: 0 additions & 3 deletions libcst/_nodes/tests/test_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -210,8 +209,6 @@ def test_valid(self, **kwargs: Any) -> None:
)
)
def test_valid_native(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled for pure python parser")
self.validate_node(**kwargs)

@data_provider(
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -188,6 +187,6 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
11 changes: 1 addition & 10 deletions libcst/_nodes/tests/test_funcdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest, DummyIndentedBlock, parse_statement_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -741,8 +740,6 @@ class FunctionDefCreationTest(CSTNodeTest):
)
)
def test_valid(self, **kwargs: Any) -> None:
if not is_native() and kwargs.get("native_only", False):
self.skipTest("Disabled for native parser")
if "native_only" in kwargs:
kwargs.pop("native_only")
self.validate_node(**kwargs)
Expand Down Expand Up @@ -891,8 +888,6 @@ def test_valid(self, **kwargs: Any) -> None:
)
)
def test_valid_native(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled for pure python parser")
self.validate_node(**kwargs)

@data_provider(
Expand Down Expand Up @@ -2223,8 +2218,6 @@ def test_valid(self, node: cst.CSTNode, code: str) -> None:
)
)
def test_valid_38(self, node: cst.CSTNode, code: str, **kwargs: Any) -> None:
if not is_native() and kwargs.get("native_only", False):
self.skipTest("disabled for pure python parser")
self.validate_node(node, code, _parse_statement_force_38)

@data_provider(
Expand Down Expand Up @@ -2252,7 +2245,7 @@ def test_valid_38(self, node: cst.CSTNode, code: str, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)

Expand All @@ -2271,6 +2264,4 @@ def test_versions(self, **kwargs: Any) -> None:
)
)
def test_parse_error(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Skipped for non-native parser")
self.assert_parses(**kwargs, expect_success=False, parser=parse_statement)
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression, parse_statement
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -126,6 +125,6 @@ def test_invalid(
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
7 changes: 2 additions & 5 deletions libcst/_nodes/tests/test_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
# 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, Callable, Optional
from typing import Any, Callable

import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.testing.utils import data_provider

parser: Optional[Callable[[str], cst.CSTNode]] = (
parse_statement if is_native() else None
)
parser: Callable[[str], cst.CSTNode] = parse_statement


class MatchTest(CSTNodeTest):
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_matrix_multiply.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
parse_expression_as,
parse_statement_as,
)
from libcst._parser.entrypoints import is_native
from libcst.testing.utils import data_provider


Expand Down Expand Up @@ -70,6 +69,6 @@ def test_valid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
4 changes: 2 additions & 2 deletions libcst/_nodes/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import libcst as cst
from libcst import parse_module, parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native

from libcst.metadata import CodeRange, MetadataWrapper, PositionProvider
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -117,7 +117,7 @@ def test_code_for_node(
def test_parser(
self, *, code: str, expected: cst.Module, enabled_for_native: bool = True
) -> None:
if is_native() and not enabled_for_native:
if not enabled_for_native:
self.skipTest("Disabled for native parser")
self.assertEqual(parse_module(code), expected)

Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.testing.utils import data_provider


Expand Down Expand Up @@ -133,6 +132,6 @@ def test_invalid(
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
7 changes: 2 additions & 5 deletions libcst/_nodes/tests/test_try.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
# 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, Callable, Optional
from typing import Any, Callable

import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest, DummyIndentedBlock
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

native_parse_statement: Optional[Callable[[str], cst.CSTNode]] = (
parse_statement if is_native() else None
)
native_parse_statement: Callable[[str], cst.CSTNode] = parse_statement


class TryTest(CSTNodeTest):
Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_tuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_expression, parse_statement
from libcst._nodes.tests.base import CSTNodeTest, parse_expression_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -286,6 +285,6 @@ def test_invalid(
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
5 changes: 0 additions & 5 deletions libcst/_nodes/tests/test_type_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -132,8 +131,6 @@ class TypeAliasCreationTest(CSTNodeTest):
)
)
def test_valid(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled in the old parser")
self.validate_node(**kwargs)


Expand Down Expand Up @@ -252,6 +249,4 @@ class TypeAliasParserTest(CSTNodeTest):
)
)
def test_valid(self, **kwargs: Any) -> None:
if not is_native():
self.skipTest("Disabled in the old parser")
self.validate_node(**kwargs)
14 changes: 6 additions & 8 deletions libcst/_nodes/tests/test_with.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

import libcst as cst
from libcst import parse_statement, PartialParserConfig
from libcst._maybe_sentinel import MaybeSentinel
from libcst._nodes.tests.base import CSTNodeTest, DummyIndentedBlock, parse_statement_as
from libcst._parser.entrypoints import is_native
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider

Expand Down Expand Up @@ -187,14 +185,14 @@ class WithTest(CSTNodeTest):
cst.WithItem(
cst.Call(
cst.Name("context_mgr"),
lpar=() if is_native() else (cst.LeftParen(),),
rpar=() if is_native() else (cst.RightParen(),),
lpar=(),
rpar=(),
)
),
),
cst.SimpleStatementSuite((cst.Pass(),)),
lpar=(cst.LeftParen() if is_native() else MaybeSentinel.DEFAULT),
rpar=(cst.RightParen() if is_native() else MaybeSentinel.DEFAULT),
lpar=(cst.LeftParen()),
rpar=(cst.RightParen()),
whitespace_after_with=cst.SimpleWhitespace(""),
),
"code": "with(context_mgr()): pass\n",
Expand Down Expand Up @@ -233,7 +231,7 @@ class WithTest(CSTNodeTest):
rpar=cst.RightParen(whitespace_before=cst.SimpleWhitespace(" ")),
),
"code": ("with ( foo(),\n" " bar(), ): pass\n"), # noqa
"parser": parse_statement if is_native() else None,
"parser": parse_statement,
"expected_position": CodeRange((1, 0), (2, 21)),
},
)
Expand Down Expand Up @@ -310,7 +308,7 @@ def test_invalid(self, **kwargs: Any) -> None:
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)

Expand Down
3 changes: 1 addition & 2 deletions libcst/_nodes/tests/test_yield.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import libcst as cst
from libcst import parse_statement
from libcst._nodes.tests.base import CSTNodeTest, parse_statement_as
from libcst._parser.entrypoints import is_native
from libcst.helpers import ensure_type
from libcst.metadata import CodeRange
from libcst.testing.utils import data_provider
Expand Down Expand Up @@ -241,6 +240,6 @@ def test_valid(
)
)
def test_versions(self, **kwargs: Any) -> None:
if is_native() and not kwargs.get("expect_success", True):
if not kwargs.get("expect_success", True):
self.skipTest("parse errors are disabled for native parser")
self.assert_parses(**kwargs)
Loading
Loading