mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
parent
9badc86fb7
commit
465fdc02a3
3 changed files with 34 additions and 9 deletions
|
@ -70,7 +70,7 @@ class samplecmdclass(cmd.Cmd):
|
|||
>>> mycmd.complete_help("12")
|
||||
[]
|
||||
>>> sorted(mycmd.complete_help(""))
|
||||
['add', 'exit', 'help', 'shell']
|
||||
['add', 'exit', 'help', 'life', 'meaning', 'shell']
|
||||
|
||||
Test for the function do_help():
|
||||
>>> mycmd.do_help("testet")
|
||||
|
@ -79,12 +79,20 @@ class samplecmdclass(cmd.Cmd):
|
|||
help text for add
|
||||
>>> mycmd.onecmd("help add")
|
||||
help text for add
|
||||
>>> mycmd.onecmd("help meaning") # doctest: +NORMALIZE_WHITESPACE
|
||||
Try and be nice to people, avoid eating fat, read a good book every
|
||||
now and then, get some walking in, and try to live together in peace
|
||||
and harmony with people of all creeds and nations.
|
||||
>>> mycmd.do_help("")
|
||||
<BLANKLINE>
|
||||
Documented commands (type help <topic>):
|
||||
========================================
|
||||
add help
|
||||
<BLANKLINE>
|
||||
Miscellaneous help topics:
|
||||
==========================
|
||||
life meaning
|
||||
<BLANKLINE>
|
||||
Undocumented commands:
|
||||
======================
|
||||
exit shell
|
||||
|
@ -115,17 +123,22 @@ class samplecmdclass(cmd.Cmd):
|
|||
This test includes the preloop(), postloop(), default(), emptyline(),
|
||||
parseline(), do_help() functions
|
||||
>>> mycmd.use_rawinput=0
|
||||
>>> mycmd.cmdqueue=["", "add", "add 4 5", "help", "help add","exit"]
|
||||
>>> mycmd.cmdloop()
|
||||
|
||||
>>> mycmd.cmdqueue=["add", "add 4 5", "", "help", "help add", "exit"]
|
||||
>>> mycmd.cmdloop() # doctest: +REPORT_NDIFF
|
||||
Hello from preloop
|
||||
help text for add
|
||||
*** invalid number of arguments
|
||||
9
|
||||
9
|
||||
<BLANKLINE>
|
||||
Documented commands (type help <topic>):
|
||||
========================================
|
||||
add help
|
||||
<BLANKLINE>
|
||||
Miscellaneous help topics:
|
||||
==========================
|
||||
life meaning
|
||||
<BLANKLINE>
|
||||
Undocumented commands:
|
||||
======================
|
||||
exit shell
|
||||
|
@ -165,6 +178,17 @@ class samplecmdclass(cmd.Cmd):
|
|||
print("help text for add")
|
||||
return
|
||||
|
||||
def help_meaning(self):
|
||||
print("Try and be nice to people, avoid eating fat, read a "
|
||||
"good book every now and then, get some walking in, "
|
||||
"and try to live together in peace and harmony with "
|
||||
"people of all creeds and nations.")
|
||||
return
|
||||
|
||||
def help_life(self):
|
||||
print("Always look on the bright side of life")
|
||||
return
|
||||
|
||||
def do_exit(self, arg):
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue