@@ -70,7 +70,7 @@ class samplecmdclass(cmd.Cmd):
70
70
>>> mycmd.complete_help("12")
71
71
[]
72
72
>>> sorted(mycmd.complete_help(""))
73
- ['add', 'exit', 'help', 'shell']
73
+ ['add', 'exit', 'help', 'life', 'meaning', ' shell']
74
74
75
75
Test for the function do_help():
76
76
>>> mycmd.do_help("testet")
@@ -79,12 +79,20 @@ class samplecmdclass(cmd.Cmd):
79
79
help text for add
80
80
>>> mycmd.onecmd("help add")
81
81
help text for add
82
+ >>> mycmd.onecmd("help meaning") # doctest: +NORMALIZE_WHITESPACE
83
+ Try and be nice to people, avoid eating fat, read a good book every
84
+ now and then, get some walking in, and try to live together in peace
85
+ and harmony with people of all creeds and nations.
82
86
>>> mycmd.do_help("")
83
87
<BLANKLINE>
84
88
Documented commands (type help <topic>):
85
89
========================================
86
90
add help
87
91
<BLANKLINE>
92
+ Miscellaneous help topics:
93
+ ==========================
94
+ life meaning
95
+ <BLANKLINE>
88
96
Undocumented commands:
89
97
======================
90
98
exit shell
@@ -115,17 +123,22 @@ class samplecmdclass(cmd.Cmd):
115
123
This test includes the preloop(), postloop(), default(), emptyline(),
116
124
parseline(), do_help() functions
117
125
>>> mycmd.use_rawinput=0
118
- >>> mycmd.cmdqueue=["", "add", "add 4 5", "help", "help add","exit"]
119
- >>> mycmd.cmdloop()
126
+
127
+ >>> mycmd.cmdqueue=["add", "add 4 5", "", "help", "help add", "exit"]
128
+ >>> mycmd.cmdloop() # doctest: +REPORT_NDIFF
120
129
Hello from preloop
121
- help text for add
122
130
*** invalid number of arguments
123
131
9
132
+ 9
124
133
<BLANKLINE>
125
134
Documented commands (type help <topic>):
126
135
========================================
127
136
add help
128
137
<BLANKLINE>
138
+ Miscellaneous help topics:
139
+ ==========================
140
+ life meaning
141
+ <BLANKLINE>
129
142
Undocumented commands:
130
143
======================
131
144
exit shell
@@ -165,6 +178,17 @@ def help_add(self):
165
178
print ("help text for add" )
166
179
return
167
180
181
+ def help_meaning (self ):
182
+ print ("Try and be nice to people, avoid eating fat, read a "
183
+ "good book every now and then, get some walking in, "
184
+ "and try to live together in peace and harmony with "
185
+ "people of all creeds and nations." )
186
+ return
187
+
188
+ def help_life (self ):
189
+ print ("Always look on the bright side of life" )
190
+ return
191
+
168
192
def do_exit (self , arg ):
169
193
return True
170
194
0 commit comments