tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
O\¬Qc@sîdZddlZddlZddlmZddlZddlZddlZdejfd„ƒYZ    dej
fd„ƒYZ dd„Z d    „Zed
krêd ejkrÁed ƒqêd ejkràe    ƒjƒqêe ƒndS(s@
Test script for the 'cmd' module
Original by Michael Schneider
iÿÿÿÿN(t test_supporttsamplecmdclasscBsVeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z    d„Z
RS(    s/
    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
    cCs    dGHdS(NsHello from preloop((tself((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytpreloopŠscCs    dGHdS(NsHello from postloop((R((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytpostloopscGs    dGHdS(Ns#This is the completedefault methode((Rtignored((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytcompletedefaultscCs    dGHdS(Nscomplete command((R((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytcomplete_command”scCsdS(N((Rts((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytdo_shell˜scCsy|jƒ}t|ƒdkr'dGHdSy#g|D]}t|ƒ^q1}Wntk
rcdGHdSX|d|dGHdS(Nis*** invalid number of argumentss*** arguments should be numbersii(tsplittlentintt
ValueError(RRtlti((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytdo_add›s # cCs    dGHdS(Nshelp text for add((R((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pythelp_add§scCstS(N(tTrue(Rtarg((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytdo_exit«s( t__name__t
__module__t__doc__RRRRR    RRR(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyRsy                            tTestAlternateInputcBsIeZdejfd„ƒYZdefd„ƒYZd„Zd„ZRS(t    simplecmdcBseZd„Zd„ZRS(cCs|j|IJdS(N(tstdout(Rtargs((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytdo_print³scCstS(N(R(RR((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pytdo_EOF¶s(RRRR(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyR±s    t
simplecmd2cBseZd„ZRS(cCs|jdIJtS(Ns*** Unknown syntax: EOF(RR(RR((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyR¼s (RRR(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyRºscCs`tjdƒ}tjƒ}|jd|d|ƒ}t|_|jƒ|j|jƒdƒdS(Nsprint test
print test2tstdinRs(Cmd) test
(Cmd) test2
(Cmd) (tStringIORtFalset use_rawinputtcmdlooptassertMultiLineEqualtgetvalue(Rtinputtoutputtcmd((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyttest_file_with_missing_final_nlÁs     
cCs­tjdƒ}tjƒ}|jd|d|ƒ}t|_|jƒ|j|jƒdƒtjdƒ}tjƒ}||_||_|jƒ|j|jƒdƒdS(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(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyttest_input_reset_at_EOFÍs     
         
(RRR(tCmdRRR)R*(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyR¯s         cCs1ddlm}tj||ƒtjtƒdS(Niÿÿÿÿ(ttest_cmd(ttestR,Rt run_doctestt run_unittestR(tverboseR,((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyt    test_mainâscCswtjdƒ}|jdtjtjgddddƒ}|jdƒ|jƒ}dGH|jdt    d    t    d
|ƒdS( Nttracet
ignoredirsitcountisreload(cmd);test_main()sWriting coverage results...t show_missingtsummarytcoverdir(
Rt import_moduletTracetsystprefixt exec_prefixtruntresultst write_resultsR(R7R2ttracertr((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyt test_coverageçs  t__main__s-cs/tmp/cmd.covers-i(RR(R:R-RtretunittestR R+RtTestCaseRtNoneR1RBRtargvR#(((sU/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_cmd.pyt<module>s       3