python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_cmd.cpython-312.opt-1.pyc

͑e@dZddlZddlZddlZddlZddlZddlmZGddejZ	GddejZdZd	Z
ed
k(rMdejvr	e
dyd
ejvre	j!yej"yy)z@
Test script for the 'cmd' module
Original by Michael Schneider
N)supportcLeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
y)
samplecmdclassa
    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 method
    >>> 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', 'life', 'meaning', '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.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
    <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 range(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 range(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()  # doctest: +REPORT_NDIFF
    Hello from preloop
    *** 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
    <BLANKLINE>
    help text for add
    Hello from postloop
    ctdy)NzHello from preloopprintselfs A/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_cmd.pypreloopzsamplecmdclass.preloops
"#ctdy)NzHello from postlooprr	s rpostloopzsamplecmdclass.postloops
#$r
ctdy)Nz"This is the completedefault methodr)r
ignoreds  rcompletedefaultzsamplecmdclass.completedefaults
23r
ctdy)Nzcomplete commandrr	s rcomplete_commandzsamplecmdclass.complete_commands
 !r
cyN)r
ss  rdo_shellzsamplecmdclass.do_shellsr
c|j}t|dk7rtdy	|Dcgc]
}t|}}t|d|dzycc}w#t$rtdYywxYw)Nz*** invalid number of argumentsz*** arguments should be numbersr)splitlenrint
ValueError)r
rlis    rdo_addzsamplecmdclass.do_addsv
GGIq6Q;34	!"#AQ#A#	ad1Q4i	$	34	s"AAAAA54A5ctdy)Nzhelp text for addrr	s rhelp_addzsamplecmdclass.help_adds
!"r
ctdy)NzTry 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.rr	s rhelp_meaningzsamplecmdclass.help_meanings
2	3	r
ctdy)Nz&Always look on the bright side of liferr	s r	help_lifezsamplecmdclass.help_lifes
67r
cyNTr)r
args  rdo_exitzsamplecmdclass.do_exitsr
N)__name__
__module____qualname____doc__rrrrrr#r%r'r)r-rr
rrrs;EN$%4"

r
rcXeZdZGddejZGddeZdZdZy)TestAlternateInputceZdZdZdZy)TestAlternateInput.simplecmdc2t||jy)Nfilerstdoutr
argss  rdo_printz%TestAlternateInput.simplecmd.do_prints$T[[)r
cyr+rr;s  rdo_EOFz#TestAlternateInput.simplecmd.do_EOFsr
N)r.r/r0r=r?rr
r	simplecmdr5s	*	r
r@ceZdZdZy)TestAlternateInput.simplecmd2c2td|jy)Nz*** Unknown syntax: EOFr7Tr9r;s  rr?z$TestAlternateInput.simplecmd2.do_EOFs+$++>r
N)r.r/r0r?rr
r
simplecmd2rBs	r
rDctjd}tj}|j||}d|_|j|j|j
dy)Nprint test
print test2stdinr:Fz(Cmd) test
(Cmd) test2
(Cmd) )ioStringIOr@use_rawinputcmdloopassertMultiLineEqualgetvaluer
inputoutputcmds    rtest_file_with_missing_final_nlz2TestAlternateInput.test_file_with_missing_final_nls]56nn5n8 
!!&//"3	r
ctjd}tj}|j||}d|_|j|j|j
dtjd}tj}||_||_|j|j|j
dy)NrFrGFz5(Cmd) test
(Cmd) test2
(Cmd) *** Unknown syntax: EOF
zprint 

z,(Cmd) 
(Cmd) 
(Cmd) *** Unknown syntax: EOF
)	rIrJrDrKrLrMrNrHr:rOs    rtest_input_reset_at_EOFz*TestAlternateInput.test_input_reset_at_EOFs56ooE&o9 
!!&//"3/	1L)	

!!&//"3/	1r
N)	r.r/r0rRCmdr@rDrSrUrr
rr3r3s(CGGY	1r
r3cL|jtj|Sr)addTestdoctestDocTestSuite)loadertestspatterns   r
load_testsr^s	MM'&&()Lr
ctjd}|jtjtj
gdd}|j
d|j}td|jdd|y)	Ntracerr)
ignoredirsr`countz4import importlib; importlib.reload(cmd); test_main()zWriting coverage results...T)show_missingsummarycoverdir)
r
import_moduleTracesysbase_prefixbase_exec_prefixrunresultsr
write_results)rer`tracerrs    r
test_coveragerpso!!'*E;;3??C4H4H"Jq*F
JJEFnnA	
'(OOthOGr
__main__z-cz/tmp/cmd.coverz-i)r1rRrhrYunittestrItestrrVrTestCaser3r^rpr.argvrLmainrr
r<module>rws
	sSWWsl01**01fHzsxx&'	
	  "


r