Module Expr Str Import alias Import alias ImportFrom alias Import alias Import alias Import alias ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam defaults body Print Str decorator_list FunctionDef arguments args NameParam defaults body Print Str decorator_list FunctionDef arguments args NameParam defaults vararg body Print Str Return decorator_list FunctionDef arguments args NameParam defaults body Print Str Return decorator_list FunctionDef arguments args NameParam NameParam defaults body Pass decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr If CompareNotEq Call NameLoad NameLoad Num body Print Str Return TryExcept body Assign NameStore ListComp Call NameLoad NameLoad comprehension NameStore NameLoad handlers ExceptHandler type NameLoad body Print Str Return Print BinOpAdd SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num decorator_list FunctionDef arguments args NameParam defaults body Print Str Return decorator_list FunctionDef arguments args NameParam NameParam defaults body Return NameLoad decorator_list decorator_list ClassDef bases AttributeLoad NameLoad attr body ClassDef bases AttributeLoad NameLoad attr body FunctionDef arguments args NameParam NameParam defaults body Print AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam NameParam defaults body Print AttributeLoad NameLoad attr Str Return NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str decorator_list decorator_list FunctionDef arguments args NameParam defaults NameLoad body ImportFrom alias Expr Call AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr keyword ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword Num keyword Num Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Print Str Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad keyword NameLoad decorator_list If CompareEq NameLoad Str body If CompareIn Str AttributeLoad NameLoad attr body Expr Call NameLoad Str orelse If CompareIn Str AttributeLoad NameLoad attr body Expr Call AttributeLoad Call NameLoad attr orelse Expr Call NameLoad
N/A N/A 
Test script for the 'cmd' module
Original by Michael Schneider
 N/A cmd N/A sys test test_support N/A re N/A unittest N/A StringIO samplecmdclass N/A N/A cmd Cmd N/A N/A 
    Instance the sampleclass:
    >>> mycmd = samplecmdclass()

    Test for the function parseline():
    >>> mycmd.parseline("")
    (None, None, '')
    >>> mycmd.parseline("?")
    ('help', '', 'help ')
    >>> mycmd.parseline("?help")
    ('help', 'help', 'help help')
    >>> mycmd.parseline("!")
    ('shell', '', 'shell ')
    >>> mycmd.parseline("!command")
    ('shell', 'command', 'shell command')
    >>> mycmd.parseline("func")
    ('func', '', 'func')
    >>> mycmd.parseline("func arg1")
    ('func', 'arg1', 'func arg1')


    Test for the function onecmd():
    >>> mycmd.onecmd("")
    >>> mycmd.onecmd("add 4 5")
    9
    >>> mycmd.onecmd("")
    9
    >>> mycmd.onecmd("test")
    *** Unknown syntax: test

    Test for the function emptyline():
    >>> mycmd.emptyline()
    *** Unknown syntax: test

    Test for the function default():
    >>> mycmd.default("default")
    *** Unknown syntax: default

    Test for the function completedefault():
    >>> mycmd.completedefault()
    This is the completedefault methode
    >>> mycmd.completenames("a")
    ['add']

    Test for the function completenames():
    >>> mycmd.completenames("12")
    []
    >>> mycmd.completenames("help")
    ['help']

    Test for the function complete_help():
    >>> mycmd.complete_help("a")
    ['add']
    >>> mycmd.complete_help("he")
    ['help']
    >>> mycmd.complete_help("12")
    []
    >>> sorted(mycmd.complete_help(""))
    ['add', 'exit', 'help', 'shell']

    Test for the function do_help():
    >>> mycmd.do_help("testet")
    *** No help on testet
    >>> mycmd.do_help("add")
    help text for add
    >>> mycmd.onecmd("help add")
    help text for add
    >>> mycmd.do_help("")
    <BLANKLINE>
    Documented commands (type help <topic>):
    ========================================
    add  help
    <BLANKLINE>
    Undocumented commands:
    ======================
    exit  shell
    <BLANKLINE>

    Test for the function print_topics():
    >>> mycmd.print_topics("header", ["command1", "command2"], 2 ,10)
    header
    ======
    command1
    command2
    <BLANKLINE>

    Test for the function columnize():
    >>> mycmd.columnize([str(i) for i in xrange(20)])
    0  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19
    >>> mycmd.columnize([str(i) for i in xrange(20)], 10)
    0  7   14
    1  8   15
    2  9   16
    3  10  17
    4  11  18
    5  12  19
    6  13

    This is a interactive test, put some commands in the cmdqueue attribute
    and let it execute
    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()
    Hello from preloop
    help text for add
    *** invalid number of arguments
    9
    <BLANKLINE>
    Documented commands (type help <topic>):
    ========================================
    add  help
    <BLANKLINE>
    Undocumented commands:
    ======================
    exit  shell
    <BLANKLINE>
    help text for add
    Hello from postloop
     preloop N/A N/A self N/A N/A N/A Hello from preloop N/A postloop N/A N/A self N/A N/A N/A Hello from postloop N/A completedefault N/A N/A self N/A ignored N/A N/A This is the completedefault methode N/A N/A complete_command N/A N/A self N/A N/A N/A complete command N/A N/A do_shell N/A N/A self s N/A N/A N/A N/A do_add N/A N/A self s N/A N/A N/A l N/A N/A s split N/A N/A N/A len l 2 N/A N/A *** invalid number of arguments N/A N/A N/A N/A l N/A N/A int i N/A i l N/A N/A N/A ValueError N/A N/A *** arguments should be numbers N/A N/A N/A N/A l N/A 0 N/A l N/A 1 N/A help_add N/A N/A self N/A N/A N/A help text for add N/A N/A do_exit N/A N/A self arg N/A N/A N/A True N/A N/A TestAlternateInput N/A N/A unittest TestCase N/A simplecmd N/A N/A cmd Cmd N/A do_print N/A N/A self args N/A N/A N/A N/A self stdout args N/A do_EOF N/A N/A self args N/A N/A N/A True N/A N/A simplecmd2 N/A simplecmd N/A do_EOF N/A N/A self args N/A N/A N/A N/A self stdout *** Unknown syntax: EOF N/A True N/A N/A test_file_with_missing_final_nl N/A N/A self N/A N/A N/A input N/A N/A StringIO StringIO print test
print test2 N/A output N/A N/A StringIO StringIO N/A cmd N/A N/A self simplecmd stdin input stdout output N/A N/A cmd use_rawinput False N/A N/A N/A cmd cmdloop N/A N/A N/A self assertMultiLineEqual N/A N/A output getvalue (Cmd) test
(Cmd) test2
(Cmd)  N/A test_input_reset_at_EOF N/A N/A self N/A N/A N/A input N/A N/A StringIO StringIO print test
print test2 N/A output N/A N/A StringIO StringIO N/A cmd N/A N/A self simplecmd2 stdin input stdout output N/A N/A cmd use_rawinput False N/A N/A N/A cmd cmdloop N/A N/A N/A self assertMultiLineEqual N/A N/A output getvalue (Cmd) test
(Cmd) test2
(Cmd) *** Unknown syntax: EOF
 N/A input N/A N/A StringIO StringIO print 

 N/A output N/A N/A StringIO StringIO N/A N/A cmd stdin input N/A N/A cmd stdout output N/A N/A N/A cmd cmdloop N/A N/A N/A self assertMultiLineEqual N/A N/A output getvalue (Cmd) 
(Cmd) 
(Cmd) *** Unknown syntax: EOF
 N/A N/A test_main N/A N/A verbose N/A None N/A test test_cmd N/A N/A N/A test_support run_doctest test_cmd verbose N/A N/A N/A test_support run_unittest TestAlternateInput N/A test_coverage N/A N/A coverdir N/A N/A N/A trace N/A N/A test_support import_module trace N/A tracer N/A N/A trace Trace ignoredirs N/A N/A sys prefix N/A sys exec_prefix trace 0 count 1 N/A N/A N/A tracer run reload(cmd);test_main() N/A r N/A N/A tracer results N/A Writing coverage results... N/A N/A N/A r write_results show_missing True summary True coverdir coverdir N/A N/A N/A __name__ __main__ N/A N/A N/A -c N/A sys argv N/A N/A N/A test_coverage /tmp/cmd.cover N/A N/A N/A -i N/A sys argv N/A N/A N/A N/A N/A samplecmdclass cmdloop N/A N/A N/A test_main