/
help_test.py
99 lines (77 loc) · 2.89 KB
/
help_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import sys
import unittest
import textwrap
from six import StringIO
from conans import __version__
from conans.test.utils.tools import TestClient
class BasicClientTest(unittest.TestCase):
def help_test(self):
client = TestClient()
client.run("")
self.assertIn('Conan commands. Type "conan <command> -h" for help', client.out)
client.run("--version")
self.assertIn("Conan version %s" % __version__, client.out)
client.run("some_unknown_command123", assert_error=True)
self.assertIn("ERROR: Unknown command 'some_unknown_command123'", client.out)
def unknown_command_test(self):
client = TestClient()
client.run("some_unknown_command123", assert_error=True)
expected_output = textwrap.dedent(
"""\
'some_unknown_command123' is not a Conan command. See 'conan --help'.
ERROR: Unknown command 'some_unknown_command123'
""")
self.assertIn(
expected_output, client.out)
# Check for a single suggestion
client.run("instal", assert_error=True)
expected_output = textwrap.dedent(
"""\
'instal' is not a Conan command. See 'conan --help'.
The most similar command is
install
ERROR: Unknown command 'instal'
""")
self.assertIn(
expected_output, client.out)
# Check for multiple suggestions
client.run("remoe", assert_error=True)
self.assertIn(
"", client.out)
expected_output = textwrap.dedent(
"""\
'remoe' is not a Conan command. See 'conan --help'.
The most similar commands are
remove
remote
ERROR: Unknown command 'remoe'
""")
self.assertIn(
expected_output, client.out)
def help_cmd_test(self):
client = TestClient()
try:
old_stdout = sys.stdout
result = StringIO()
sys.stdout = result
client.run("help new")
finally:
sys.stdout = old_stdout
self.assertIn("Creates a new package recipe template with a 'conanfile.py'",
result.getvalue())
try:
old_stdout = sys.stdout
result = StringIO()
sys.stdout = result
client.run("help build")
finally:
sys.stdout = old_stdout
self.assertIn("Calls your local conanfile.py 'build()' method",
result.getvalue())
client.run("help")
self.assertIn("Creator commands",
client.out)
def help_cmd_error_test(self):
client = TestClient()
client.run("help not-exists", assert_error=True)
self.assertIn("ERROR: Unknown command 'not-exists'", client.out)