HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_cmd.cpython-37.opt-1.pyc
B

��gi�@s�dZddlZddlZddlZddlZddlmZGdd�dej�ZGdd�dej	�Z
ddd	�Zd
d�Ze
dkr�d
ejkr�ed�ndejkr�e���ne�dS)z@
Test script for the 'cmd' module
Original by Michael Schneider
�N)�supportc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�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', '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 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()
    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td�dS)NzHello from preloop)�print)�self�r�)/usr/local/lib/python3.7/test/test_cmd.py�preloop�szsamplecmdclass.preloopcCstd�dS)NzHello from postloop)r)rrrr�postloop�szsamplecmdclass.postloopcGstd�dS)Nz"This is the completedefault method)r)rZignoredrrr�completedefault�szsamplecmdclass.completedefaultcCstd�dS)Nzcomplete command)r)rrrr�complete_command�szsamplecmdclass.complete_commandcCsdS)Nr)r�srrr�do_shell�szsamplecmdclass.do_shellcCsh|��}t|�dkr td�dSydd�|D�}Wntk
rNtd�dSXt|d|d�dS)N�z*** invalid number of argumentscSsg|]}t|��qSr)�int)�.0�irrr�
<listcomp>�sz)samplecmdclass.do_add.<locals>.<listcomp>z*** arguments should be numbersr�)�split�lenr�
ValueError)rr�lrrr�do_add�szsamplecmdclass.do_addcCstd�dS)Nzhelp text for add)r)rrrr�help_add�szsamplecmdclass.help_addcCsdS)NTr)r�argrrr�do_exit�szsamplecmdclass.do_exitN)�__name__�
__module__�__qualname__�__doc__rr	r
rr
rrrrrrrr
syrc@s>eZdZGdd�dej�ZGdd�de�Zdd�Zdd�Zd	S)
�TestAlternateInputc@seZdZdd�Zdd�ZdS)zTestAlternateInput.simplecmdcCst||jd�dS)N)�file)r�stdout)r�argsrrr�do_print�sz%TestAlternateInput.simplecmd.do_printcCsdS)NTr)rr#rrr�do_EOF�sz#TestAlternateInput.simplecmd.do_EOFN)rrrr$r%rrrr�	simplecmd�sr&c@seZdZdd�ZdS)zTestAlternateInput.simplecmd2cCstd|jd�dS)Nz*** Unknown syntax: EOF)r!T)rr")rr#rrrr%�sz$TestAlternateInput.simplecmd2.do_EOFN)rrrr%rrrr�
simplecmd2�sr'cCsBt�d�}t��}|j||d�}d|_|��|�|��d�dS)Nzprint test
print test2)�stdinr"Fz(Cmd) test
(Cmd) test2
(Cmd) )�io�StringIOr&�use_rawinput�cmdloop�assertMultiLineEqual�getvalue)r�input�output�cmdrrr�test_file_with_missing_final_nl�s

z2TestAlternateInput.test_file_with_missing_final_nlcCsxt�d�}t��}|j||d�}d|_|��|�|��d�t�d�}t��}||_||_|��|�|��d�dS)Nzprint test
print test2)r(r"Fz5(Cmd) test
(Cmd) test2
(Cmd) *** Unknown syntax: EOF
zprint 

z,(Cmd) 
(Cmd) 
(Cmd) *** Unknown syntax: EOF
)	r)r*r'r+r,r-r.r(r")rr/r0r1rrr�test_input_reset_at_EOF�s



z*TestAlternateInput.test_input_reset_at_EOFN)	rrrr1�Cmdr&r'r2r3rrrrr �s	r cCs&ddlm}t�||�t�t�dS)Nr)�test_cmd)�testr5rZrun_doctestZrun_unittestr )�verboser5rrr�	test_main�sr8cCsPt�d�}|jtjtjgddd�}|�d�|��}td�|j	dd|d�dS)	N�tracerr)Z
ignoredirsr9�countz4import importlib; importlib.reload(cmd); test_main()zWriting coverage results...T)Zshow_missingZsummary�coverdir)
r�
import_moduleZTrace�sys�base_prefix�base_exec_prefix�run�resultsrZ
write_results)r;r9Ztracer�rrrr�
test_coverage�s


rC�__main__z-cz/tmp/cmd.coverz-i)N)rr1r=Zunittestr)r6rr4rZTestCaser r8rCr�argvr,rrrr�<module>s 3