mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
#
|
|
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from libcst._parser.entrypoints import is_native
|
|
from libcst.testing.utils import UnitTest
|
|
|
|
|
|
class TestCodemodCLI(UnitTest):
|
|
def test_codemod_formatter_error_input(self) -> None:
|
|
rlt = subprocess.run(
|
|
[
|
|
"python",
|
|
"-m",
|
|
"libcst.tool",
|
|
"codemod",
|
|
"remove_unused_imports.RemoveUnusedImportsCommand",
|
|
str(Path(__file__).parent / "codemod_formatter_error_input.py.txt"),
|
|
],
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
)
|
|
version = sys.version_info
|
|
if version[0] == 3 and version[1] == 6 and not is_native():
|
|
self.assertIn(
|
|
"ParserSyntaxError: Syntax Error @ 14:11.",
|
|
rlt.stderr.decode("utf-8"),
|
|
)
|
|
else:
|
|
self.assertIn(
|
|
"error: cannot format -: Cannot parse: 13:10: async with AsyncExitStack() as stack:",
|
|
rlt.stderr.decode("utf-8"),
|
|
)
|