Skip to content

Commit b668c8c

Browse files
committed
Remove dead code
Add no argument cases
1 parent c1e50aa commit b668c8c

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

pythainlp/__main__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ def main(argv=None):
3333
if hasattr(cli, args.command):
3434
command = getattr(cli, args.command)
3535
command.App(argv)
36-
else:
37-
print(f"Command not available: {args.command}")
38-
print("Please run with --help for list of available commands.")
3936

4037

4138
if __name__ == "__main__":

tests/test_cli.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,42 @@ def test_cli_main(self):
2323

2424
def test_cli_data(self):
2525
self.assertIsInstance(getattr(cli, "data"), ModuleType)
26+
27+
with self.assertRaises(SystemExit) as ex:
28+
cli.data.App(["thainlp", "data"])
29+
self.assertEqual(ex.exception.code, 2)
30+
2631
self.assertIsNotNone(cli.data.App(["thainlp", "data", "catalog"]))
2732
self.assertIsNotNone(cli.data.App(["thainlp", "data", "path"]))
33+
self.assertIsNotNone(cli.data.App(["thainlp", "data", "get", "test"]))
2834
self.assertIsNotNone(cli.data.App(["thainlp", "data", "info", "test"]))
35+
self.assertIsNotNone(cli.data.App(["thainlp", "data", "rm", "test"]))
2936
self.assertIsNotNone(
3037
cli.data.App(["thainlp", "data", "get", "NOT_EXIST"])
3138
)
39+
self.assertIsNotNone(
40+
cli.data.App(["thainlp", "data", "info", "NOT_EXIST"])
41+
)
3242
self.assertIsNotNone(
3343
cli.data.App(["thainlp", "data", "rm", "NOT_EXIST"])
3444
)
3545

3646
def test_cli_soundex(self):
3747
self.assertIsInstance(getattr(cli, "soundex"), ModuleType)
48+
49+
with self.assertRaises(SystemExit) as ex:
50+
cli.data.App(["thainlp", "soundex"])
51+
self.assertEqual(ex.exception.code, 2)
52+
3853
self.assertIsNotNone(cli.soundex.App(["thainlp", "soundex", "ทดสอบ"]))
3954

4055
def test_cli_tag(self):
4156
self.assertIsInstance(getattr(cli, "tag"), ModuleType)
57+
58+
with self.assertRaises(SystemExit) as ex:
59+
cli.data.App(["thainlp", "tag"])
60+
self.assertEqual(ex.exception.code, 2)
61+
4262
self.assertIsNotNone(
4363
cli.tag.App(
4464
[
@@ -65,7 +85,17 @@ def test_cli_tag(self):
6585
)
6686

6787
def test_cli_tokenize(self):
68-
self.assertIsInstance(getattr(cli, "data"), ModuleType)
88+
self.assertIsInstance(getattr(cli, "tokenize"), ModuleType)
89+
90+
with self.assertRaises(SystemExit) as ex:
91+
cli.data.App(["thainlp", "tokenize"])
92+
self.assertEqual(ex.exception.code, 2)
93+
94+
self.assertIsNotNone(
95+
cli.tokenize.App(
96+
["thainlp", "tokenize", "NOT_EXIST", "ไม่มีอยู่ จริง",]
97+
)
98+
)
6999
self.assertIsNotNone(
70100
cli.tokenize.App(
71101
[

0 commit comments

Comments
 (0)