LibCST/libcst/codemod/tests/test_codemod_cli.py
Zsolt Dollenstein c44ff0500b
Fix license headers (#560)
* Facebook -> Meta

* remove year from doc copyright
2021-12-28 11:55:18 +00:00

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"),
)