LibCST/libcst/tests/test_exceptions.py
Jennifer Taylor 3dec7be6ef Export things from libcst's base__init__.py
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.
2019-07-26 12:48:22 -07:00

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)