Nexus File Manager
v2.0
🏠
Dashboard
⚡
System
🌐
›
opt
›
alt
›
python38
›
lib64
›
python3.8
›
test
›
__pycache__
Quick:
⬆️ Parent
🌐 Root
🏠 Home
🌍 WWW
📁 Temp
⚙️ Etc
📤 Upload
📁 Create
⚡ WordPress Admin
🔄 Refresh
✏️ test_cmd.cpython-38.opt-1.pyc
← Back
U i�fi � @ s� d Z ddlZddlZddlZddlZddlmZ G dd� dej�ZG dd� dej �Z ddd �Zd d� Ze dkr�d ejkr�ed� ndejkr�e� �� ne� dS )z@ Test script for the 'cmd' module Original by Michael Schneider � N)�supportc @ sP e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � 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 c C s t d� d S )NzHello from preloop��print��self� r �2/opt/alt/python38/lib64/python3.8/test/test_cmd.py�preloop� s zsamplecmdclass.preloopc C s t d� d S )NzHello from postloopr r r r r �postloop� s zsamplecmdclass.postloopc G s t d� d S )Nz"This is the completedefault methodr )r Zignoredr r r �completedefault� s zsamplecmdclass.completedefaultc C s t d� d S )Nzcomplete commandr r r r r �complete_command� s zsamplecmdclass.complete_commandc C s d S )Nr )r �sr r r �do_shell� s zsamplecmdclass.do_shellc C sj |� � }t|�dkr td� d S zdd� |D �}W n tk rP td� Y d S X t|d |d � d S )N� z*** invalid number of argumentsc S s g | ]}t |��qS r )�int)�.0�ir r r � <listcomp>� s z)samplecmdclass.do_add.<locals>.<listcomp>z*** arguments should be numbersr � )�split�lenr � ValueError)r r �lr r r �do_add� s zsamplecmdclass.do_addc C s t d� d S )Nzhelp text for addr r r r r �help_add� s zsamplecmdclass.help_addc C s dS �NTr )r �argr r r �do_exit� s zsamplecmdclass.do_exitN)�__name__� __module__�__qualname__�__doc__r r r r r r r r r r r r r s zr c @ s>