-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #968 from bact/add-cli-tests
Make CLI able to handle Unicode characters output on Windows console
- Loading branch information
Showing
10 changed files
with
110 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# SPDX-FileCopyrightText: 2016-2024 PyThaiNLP Project | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import unittest | ||
|
||
from pythainlp import __main__, cli | ||
from pythainlp.cli.benchmark import App as BenchmarkApp | ||
from pythainlp.cli.data import App as DataApp | ||
from pythainlp.cli.tokenize import App as TokenizeApp | ||
|
||
|
||
class CliTestCaseX(unittest.TestCase): | ||
def test_cli_benchmark(self): | ||
self.assertTrue(hasattr(cli, "benchmark")) | ||
|
||
with self.assertRaises(SystemExit) as ex: | ||
DataApp(["thainlp", "benchmark"]) | ||
self.assertEqual(ex.exception.code, 2) | ||
|
||
self.assertIsNotNone( | ||
BenchmarkApp( | ||
[ | ||
"thainlp", | ||
"benchmark", | ||
"word-tokenization", | ||
"--input-file", | ||
"./tests/data/input.txt", | ||
"--test-file", | ||
"./tests/data/test.txt", | ||
"--save-details", | ||
] | ||
) | ||
) | ||
|
||
def test_cli_tokenize(self): | ||
self.assertIsNotNone( | ||
TokenizeApp( | ||
[ | ||
"thainlp", | ||
"tokenize", | ||
"sent", | ||
"-s", | ||
"|", | ||
( | ||
"ถ้าฉันยิงกระต่ายได้ ฉันก็ยิงฟาสซิสต์ได้" | ||
"กระสุนสำหรับสมองของคุณวันนี้" | ||
"แต่คุณก็จะลืมมันไปทั้งหมดอีกครั้ง" | ||
), | ||
] | ||
) | ||
) |