%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/test_cmd.pyo


Nac@sdZddlZddlZddlmZddlZddlZddlZdejfdYZ	dej
fdYZddZ
d	Zed
krdejkredqd
ejkre	jqe
ndS(s@
Test script for the 'cmd' module
Original by Michael Schneider
iN(ttest_supporttsamplecmdclasscBsVeZdZdZdZdZdZdZdZdZ	dZ
RS(	s0
    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 an 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
    cCs	dGHdS(NsHello from preloop((tself((s)/usr/local/lib/python2.7/test/test_cmd.pytpreloopscCs	dGHdS(NsHello from postloop((R((s)/usr/local/lib/python2.7/test/test_cmd.pytpostloopscGs	dGHdS(Ns#This is the completedefault methode((Rtignored((s)/usr/local/lib/python2.7/test/test_cmd.pytcompletedefaultscCs	dGHdS(Nscomplete command((R((s)/usr/local/lib/python2.7/test/test_cmd.pytcomplete_commandscCsdS(N((Rts((s)/usr/local/lib/python2.7/test/test_cmd.pytdo_shellscCsy|j}t|dkr'dGHdSy#g|D]}t|^q1}Wntk
rcdGHdSX|d|dGHdS(Nis*** invalid number of argumentss*** arguments should be numbersii(tsplittlentintt
ValueError(RRtlti((s)/usr/local/lib/python2.7/test/test_cmd.pytdo_adds#
cCs	dGHdS(Nshelp text for add((R((s)/usr/local/lib/python2.7/test/test_cmd.pythelp_addscCstS(N(tTrue(Rtarg((s)/usr/local/lib/python2.7/test/test_cmd.pytdo_exits(t__name__t
__module__t__doc__RRRRR	RRR(((s)/usr/local/lib/python2.7/test/test_cmd.pyRsy							tTestAlternateInputcBsIeZdejfdYZdefdYZdZdZRS(t	simplecmdcBseZdZdZRS(cCs|j|IJdS(N(tstdout(Rtargs((s)/usr/local/lib/python2.7/test/test_cmd.pytdo_printscCstS(N(R(RR((s)/usr/local/lib/python2.7/test/test_cmd.pytdo_EOFs(RRRR(((s)/usr/local/lib/python2.7/test/test_cmd.pyRs	t
simplecmd2cBseZdZRS(cCs|jdIJtS(Ns*** Unknown syntax: EOF(RR(RR((s)/usr/local/lib/python2.7/test/test_cmd.pyRs
(RRR(((s)/usr/local/lib/python2.7/test/test_cmd.pyRscCs`tjd}tj}|jd|d|}t|_|j|j|jddS(Nsprint test
print test2tstdinRs(Cmd) test
(Cmd) test2
(Cmd) (tStringIORtFalsetuse_rawinputtcmdlooptassertMultiLineEqualtgetvalue(Rtinputtoutputtcmd((s)/usr/local/lib/python2.7/test/test_cmd.pyttest_file_with_missing_final_nls	
cCstjd}tj}|jd|d|}t|_|j|j|jdtjd}tj}||_||_|j|j|jddS(Nsprint test
print test2RRs5(Cmd) test
(Cmd) test2
(Cmd) *** Unknown syntax: EOF
sprint 

s,(Cmd) 
(Cmd) 
(Cmd) *** Unknown syntax: EOF
(	R RR!R"R#R$R%RR(RR&R'R(((s)/usr/local/lib/python2.7/test/test_cmd.pyttest_input_reset_at_EOFs	
		
(RRR(tCmdRRR)R*(((s)/usr/local/lib/python2.7/test/test_cmd.pyRs		cCs1ddlm}tj||tjtdS(Ni(ttest_cmd(ttestR,Rtrun_doctesttrun_unittestR(tverboseR,((s)/usr/local/lib/python2.7/test/test_cmd.pyt	test_mainscCswtjd}|jdtjtjgdddd}|jd|j}dGH|jdt	d	t	d
|dS(Nttracet
ignoredirsitcountisreload(cmd);test_main()sWriting coverage results...tshow_missingtsummarytcoverdir(
Rt
import_moduletTracetsystprefixtexec_prefixtruntresultst
write_resultsR(R7R2ttracertr((s)/usr/local/lib/python2.7/test/test_cmd.pyt
test_coverages
t__main__s-cs/tmp/cmd.covers-i(RR(R:R-RtretunittestR R+RtTestCaseRtNoneR1RBRtargvR#(((s)/usr/local/lib/python2.7/test/test_cmd.pyt<module>s 3		


Zerion Mini Shell 1.0