Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_cmd.cpython-38.opt-1.pyc
U

>��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�,/opt/cppython/lib/python3.8/test/test_cmd.py�preloop�szsamplecmdclass.preloopcCstd�dS)NzHello from postlooprrrrr	�postloop�szsamplecmdclass.postloopcGstd�dS)Nz"This is the completedefault methodr)rZignoredrrr	�completedefault�szsamplecmdclass.completedefaultcCstd�dS)Nzcomplete commandrrrrr	�complete_command�szsamplecmdclass.complete_commandcCsdS)Nr)r�srrr	�do_shell�szsamplecmdclass.do_shellcCsj|��}t|�dkr td�dSzdd�|D�}Wntk
rPtd�YdSXt|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 addrrrrr	�help_add�szsamplecmdclass.help_addcCsdS�NTr)r�argrrr	�do_exit�szsamplecmdclass.do_exitN)�__name__�
__module__�__qualname__�__doc__r
rrr
rrrrrrrr	r
sz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_printcCsdSrrr(rrr	�do_EOF�sz#TestAlternateInput.simplecmd.do_EOFN)rr r!r*r+rrrr	�	simplecmd�sr,c@seZdZdd�ZdS)zTestAlternateInput.simplecmd2cCstd|jd�dS)Nz*** Unknown syntax: EOFr$Tr&r(rrr	r+�sz$TestAlternateInput.simplecmd2.do_EOFN)rr r!r+rrrr	�
simplecmd2�sr-cCsBt�d�}t��}|j||d�}d|_|��|�|��d�dS)N�print 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)Nr.r/Fz5(Cmd) test
(Cmd) test2
(Cmd) *** Unknown syntax: EOF
zprint 

z,(Cmd) 
(Cmd) 
(Cmd) *** Unknown syntax: EOF
)	r1r2r-r3r4r5r6r0r'r7rrr	�test_input_reset_at_EOF�s 

�

�z*TestAlternateInput.test_input_reset_at_EOFN)	rr r!r:�Cmdr,r-r;r<rrrr	r#�s	r#cCs&ddlm}t�||�t�t�dS)Nr)�test_cmd)�testr>rZrun_doctestZrun_unittestr#)�verboser>rrr	�	test_main�srAcCsPt�d�}|jtjtjgddd�}|�d�|��}td�|j	dd|d�dS)	N�tracerr)Z
ignoredirsrB�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)rDrBZtracer�rrrr	�
test_coverage�s
�
rL�__main__z-cz/tmp/cmd.coverz-i)N)r"r:rFZunittestr1r?rr=rZTestCaser#rArLr�argvr4rrrr	�<module>s 3
	




F1le Man4ger