Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_readline.cpython-39.opt-2.pyc

a

��g.5�@sddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
mZmZmZddlmZed�Zeed�r�dejvZnejo�d	ejvZd
d�Ze
�eed�d
�Gdd�de
j��ZGdd�de
j�Zddd�Zedk�re
��dS)�)�	ExitStack)�EION)�
import_module�unlink�temp_dir�TESTFN�verbose)�assert_python_ok�readline�_READLINE_LIBRARY_VERSIONzEditLine wrapper�libeditcCs^trZttd�r2tdtjd���tdtjd���ttd�rLtdtj���tdt���dS)N�_READLINE_VERSIONzreadline version: z#xzreadline runtime version: rzreadline library version: zuse libedit emulation? )r�hasattrr
�printr
Z_READLINE_RUNTIME_VERSIONr�is_editline�rr�./usr/local/lib/python3.9/test/test_readline.py�setUpModules

r�
clear_historyzXThe history update test cannot be run because the clear_history method is not available.c@s6eZdZdd�Ze�eed�d�dd��Zdd�Z	d	S)
�TestHistoryManipulationcCs�t��t�d�t�d�|�t�d�d�|�t�d�d�|�t�d�d�t�dd�|�t�d�d�|�t�d�d�|�t�d�d�|�t��d�t�d�|�t�d�d�|�t�d�d�|�t��d�dS)N�
first line�second liner��z
replaced line)r
r�add_history�assertEqual�get_history_item�replace_history_item�get_current_history_lengthZremove_history_item)�selfrrr�testHistoryUpdates/s


z*TestHistoryManipulation.testHistoryUpdates�append_history_filezappend_history not availablecCsVtjdd�}|��|j}|�t|�t��t�d�t�d�t�	|�t��|�
t��d�t�|�|�
t��d�|�
t�
d�d�|�
t�
d�d�t�d|�t��t�|�|�
t��d�|�
t�
d�d�|�
t�
d�d�|�
t�
d�d�t�|�|�t��t�d|�Wd�n1�s>0Yt�	|�dS)	NF)�deleterrrrr�)�tempfile�NamedTemporaryFile�close�name�
addCleanuprr
rr�write_history_filerr�read_history_filerr!�osZassertRaises�FileNotFoundError)rZhfileZ	hfilenamerrr�test_write_read_appendFs2





,z.TestHistoryManipulation.test_write_read_appendc
Cs�t��zt�d�Wn6tyL}z|�dt|��WYd}~n
d}~00t�d�t�dd�t�t�|�	t
jt�t��t�t�t
r�t�d�|�t�d�d�|�t�d�d�dS)Nu	entrée 1� Locale cannot encode test data: u	entrée 2ru
entrée 22�dummyr)r
rr�UnicodeEncodeError�skipTest�formatrr)rr(r+�remover*rrr)r�errrrr�test_nonascii_historyms(



z-TestHistoryManipulation.test_nonascii_historyN)
�__name__�
__module__�__qualname__r �unittest�
skipUnlessrr
r-r5rrrrr%s
�
%rc@sneZdZe�ejdkoed�dd��ZdZ	dd�Z
dd	�Zd
d�Ze�ejdkd
�e�ed�dd���Z
dS)�TestReadlineiz%not supported in this library versioncCs$tdddd�\}}}|�|d�dS)N�-czimport readlinezxterm-256color)ZTERM�)r	r)r�rc�stdout�stderrrrr�	test_init�s�zTestReadline.test_initzvimport readline
readline.set_auto_history({})
input()
print("History length:", readline.get_current_history_length())
cCs t|j�d��}|�d|�dS)NTsHistory length: 1��run_pty�auto_history_scriptr2�assertIn�r�outputrrr�test_auto_history_enabled�sz&TestReadline.test_auto_history_enabledcCs t|j�d��}|�d|�dS)NFsHistory length: 0rBrFrrr�test_auto_history_disabled�sz'TestReadline.test_auto_history_disabledc
Cst�tjd�}|dvr&|�d|���zt�d�Wn6tyj}z|�dt|��WYd}~n
d}~00d}d}|dtd�7}|d	7}|d
7}|d7}t	||�}|�
d|�|�
d
|�|�
d|�ts�ttd�r�|�
d|�|�
d|�d}|�
d|d|�|�
d||�dS)N)�CZPOSIXzthe LC_CTYPE locale is uëïr.a*import readline

is_editline = readline.__doc__ and "libedit" in readline.__doc__
inserted = "[\xEFnserted]"
macro = "|t\xEB[after]"
set_pre_input_hook = getattr(readline, "set_pre_input_hook", None)
if is_editline or not set_pre_input_hook:
    # The insert_line() call via pre_input_hook() does nothing with Editline,
    # so include the extra text that would have been inserted here
    macro = inserted + macro

if is_editline:
    readline.parse_and_bind(r'bind ^B ed-prev-char')
    readline.parse_and_bind(r'bind "\t" rl_complete')
    readline.parse_and_bind(r'bind -s ^A "{}"'.format(macro))
else:
    readline.parse_and_bind(r'Control-b: backward-char')
    readline.parse_and_bind(r'"\t": complete')
    readline.parse_and_bind(r'set disable-completion off')
    readline.parse_and_bind(r'set show-all-if-ambiguous off')
    readline.parse_and_bind(r'set show-all-if-unmodified off')
    readline.parse_and_bind(r'Control-a: "{}"'.format(macro))

def pre_input_hook():
    readline.insert_text(inserted)
    readline.redisplay()
if set_pre_input_hook:
    set_pre_input_hook(pre_input_hook)

def completer(text, state):
    if text == "t\xEB":
        if state == 0:
            print("text", ascii(text))
            print("line", ascii(readline.get_line_buffer()))
            print("indexes", readline.get_begidx(), readline.get_endidx())
            return "t\xEBnt"
        if state == 1:
            return "t\xEBxt"
    if text == "t\xEBx" and state == 0:
        return "t\xEBxt"
    return None
readline.set_completer(completer)

def display(substitution, matches, longest_match_length):
    print("substitution", ascii(substitution))
    print("matches", ascii(matches))
readline.set_completion_display_matches_hook(display)

print("result", ascii(input()))
print("history", ascii(readline.get_history_item(1)))
��z[after]s		sx	�
stext 't\xeb'
s#line '[\xefnserted]|t\xeb[after]'
sindexes 11 13
Zset_pre_input_hookssubstitution 't\xeb'
s matches ['t\xebnt', 't\xebxt']
s'[\xefnserted]|t\xebxt[after]'sresult s
shistory )
�locale�	setlocale�LC_CTYPEr1r
rr0r2�lenrCrErr)r�locr4�script�inputrGZexpectedrrr�
test_nonascii�s.(4
zTestReadline.test_nonasciiiz3this readline version does not support history-sizez-editline history size configuration is brokenc
	CsZd}t���8}tj�|d�}t|d��}|�d|�Wd�n1sJ0Ytj�|d�}t|d��6}d�dd�t|d	�D��}|�|�Wd�n1s�0Yd
}ttj�}||d<||d<t	|d
|d�t|d��}|�
�}	Wd�n1�s0Y|�t|	�|�|�|	d�
�d�Wd�n1�sL0YdS)N�
�inputrc�wbsset history-size %d
�historyr=css|]}d|VqdS)sitem %d
Nr)�.0�irrr�	<genexpr>s�z1TestReadline.test_history_size.<locals>.<genexpr>rz�
import os
import readline

history_file = os.environ["HISTORY_FILE"]
readline.read_history_file(history_file)
input()
readline.write_history_file(history_file)
ZINPUTRCZHISTORY_FILEslast input
)rT�env�rb���s
last input)rr+�path�join�open�write�range�dict�environrC�	readlinesrrQ�strip)
rZhistory_sizeZtest_dirrW�fZhistory_file�datarSr]�linesrrr�test_history_size�s(
,

�(

(zTestReadline.test_history_sizeN)r6r7r8r9ZskipIfr
r
rrArDrHrIrUrlrrrrr;�s�
X��r;�dummy input
cCs�td�}t�}|��\}}tjd|f}tj|||||d�}t�|�t	���f}	|	�
|�dd�}
|	�|
|�|	�tj|�|	�
t�
��}|�|tjtjB�t�|d�|��D]�\}}
|
tj@�r2zt�|d�}Wn6t�y
}z|jtkr�d}WYd}~n
d}~00|�s(|Wd�S|�|�|
tj@r�z|t�||�d�}Wn8t�y�}z|jtk�rt�d}WYd}~n
d}~00|s�|�|tj�q�q�Wd�n1�s�0YdS)	N�ptyr<)�stdinr?r@r]cSs$z|��WntyYn0dS)N)�	terminate�ProcessLookupError)�procrrrrp)szrun_pty.<locals>.terminateFir=)r�	bytearray�openpty�sys�
executable�
subprocess�Popenr+r&r�
enter_context�callback�	selectors�SelectSelector�register�
EVENT_READ�EVENT_WRITE�set_blocking�select�read�OSError�errnor�extendrc�modify)rSrTr]rnrGZmasterZslave�argsrr�cleanuprpZsel�_�events�chunkr4rrrrC sD





rC�__main__)rmN) �
contextlibrr�rrNr+r{rwrur$r9Ztest.supportrrrrrZtest.support.script_helperr	r
rrr�__doc__rr:ZTestCaserr;rCr6�mainrrrr�<module>s0
�Y 
2


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists