mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
Go through and clean up where we export things from in the top level directories. This is the first pass at cleaning up the public API. In this diff I clean up all top-level exports that were coming out of .py files and instead export them from libcst's base module itself. I also didn't export a few of the things defined in newly underscored files because they were only used internally.
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
# pyre-strict
|
|
from textwrap import dedent
|
|
|
|
from libcst._exceptions import ParserSyntaxError
|
|
from libcst.testing.utils import UnitTest, data_provider
|
|
|
|
|
|
class ExceptionsTest(UnitTest):
|
|
@data_provider(
|
|
[
|
|
(
|
|
ParserSyntaxError(
|
|
message="some message",
|
|
encountered=None, # EOF
|
|
expected=None, # EOF
|
|
pos=(1, 0),
|
|
lines=["abcd"],
|
|
),
|
|
dedent(
|
|
"""
|
|
Syntax Error: some message @ 1:1.
|
|
Encountered end of file (EOF), but expected end of file (EOF).
|
|
|
|
abcd
|
|
^
|
|
"""
|
|
).strip(),
|
|
),
|
|
(
|
|
ParserSyntaxError(
|
|
message="some message",
|
|
encountered="encountered_value",
|
|
expected=["expected_value"],
|
|
pos=(1, 2),
|
|
lines=["\tabcd\r\n"],
|
|
),
|
|
dedent(
|
|
"""
|
|
Syntax Error: some message @ 1:10.
|
|
Encountered 'encountered_value', but expected one of ['expected_value'].
|
|
|
|
abcd
|
|
^
|
|
"""
|
|
).strip(),
|
|
),
|
|
]
|
|
)
|
|
def test_parser_syntax_error_str(
|
|
self, err: ParserSyntaxError, expected: str
|
|
) -> None:
|
|
self.assertEqual(str(err), expected)
|