Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.11/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.11/test/__pycache__/test_readline.cpython-311.pyc

�

SԚg	3���dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZe
d��Zeed	��r
d
ejvZnejodejvZd�Zejeed
��d��Gd�dej����ZGd�dej��Zedkrej��dSdS)z:
Very minimal unittests for parts of the readline module.
�N)�verbose)�
import_module)�unlink�temp_dir�TESTFN)�run_pty)�assert_python_ok�readline�_READLINE_LIBRARY_VERSIONzEditLine wrapper�libeditc�F�tr�ttd��r:tdtjd����tdtjd����ttd��rtdtj����tdt����dSdS)N�_READLINE_VERSIONzreadline version: z#xzreadline runtime version: rzreadline library version: zuse libedit emulation? )r�hasattrr
�printr�_READLINE_RUNTIME_VERSIONr�is_editline���//usr/local/lib/python3.11/test/test_readline.py�setUpModulers����7��8�0�1�1�	X��F�x�'A�F�F�F�G�G�G��V�x�/Q�V�V�V�W�W�W��8�8�9�9�	W��U�x�/Q�U�U�V�V�V�
�5��5�5�6�6�6�6�6�7�7r�
clear_historyzXThe history update test cannot be run because the clear_history method is not available.c�f�eZdZdZd�Zejeed��d��d���Z	d�Z
dS)�TestHistoryManipulationz�
    These tests were added to check that the libedit emulation on OSX and the
    "real" readline have the same interface for history manipulation. That's
    why the tests cover only a small subset of the interface.
    c��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_length�remove_history_item)�selfs r�testHistoryUpdatesz*TestHistoryManipulation.testHistoryUpdates/s������ � � ����\�*�*�*����]�+�+�+�����2�2�1�5�5�t�<�<�<�����2�2�1�5�5�|�D�D�D�����2�2�1�5�5�}�E�E�E��%�%�a��9�9�9�����2�2�1�5�5�t�<�<�<�����2�2�1�5�5��G�G�G�����2�2�1�5�5�}�E�E�E�����<�<�>�>��B�B�B��$�$�Q�'�'�'�����2�2�1�5�5�t�<�<�<�����2�2�1�5�5�}�E�E�E�����<�<�>�>��B�B�B�B�Br�append_history_filezappend_history not availablec�$�tjd���}|���|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��tj|��	t�d|��tj|��n#t $rYnwxYwt�	|��dS)	NF)�deleterrrrr�)�tempfile�NamedTemporaryFile�close�name�
addCleanuprr
rr�write_history_filer r#�read_history_filer!r'�os�FileNotFoundError)r%�hfile�	hfilenames   r�test_write_read_appendz.TestHistoryManipulation.test_write_read_appendFs����+�5�9�9�9��
���
�
�
��J�	�����	�*�*�*�	��� � � ����\�*�*�*����]�+�+�+��#�#�I�.�.�.���� � � �����<�<�>�>��B�B�B��"�"�9�-�-�-�����<�<�>�>��B�B�B�����2�2�1�5�5�|�D�D�D�����2�2�1�5�5�}�E�E�E�	�$�$�Q�	�2�2�2���� � � ��"�"�9�-�-�-�����<�<�>�>��B�B�B�����2�2�1�5�5�|�D�D�D�����2�2�1�5�5�}�E�E�E�����2�2�1�5�5�}�E�E�E�	�	�)����	!��(�(��I�6�6�6�
�I�i� � � � ��!�	�	�	��D�	����	�#�#�I�.�.�.�.�.s�6K&�&
K3�2K3c�D�t���	t�d��n<#t$r/}|�dt|��z��Yd}~nd}~wwxYwt�d��t�dd��t�t��|�	tjt��t���t�t��trt�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�formatr"r0rr/r2�remover1rr r!)r%�errs  r�test_nonascii_historyz-TestHistoryManipulation.test_nonascii_historytsg����� � � �	L�� � ��-�-�-�-��!�	L�	L�	L��M�M�<�v�c�{�{�J�K�K�K�K�K�K�K�K�����	L�������[�)�)�)��%�%�a��6�6�6��#�#�F�+�+�+�����	�6�*�*�*���� � � ��"�"�6�*�*�*��	*�
� � ��)�)�)�����2�2�1�5�5�{�C�C�C�����2�2�1�5�5�|�D�D�D�D�Ds�6�
A/�%A*�*A/N)�__name__�
__module__�__qualname__�__doc__r&�unittest�
skipUnlessrr
r6r?rrrrr%s���������C�C�C�.�X�����+@�A�A�7�9�9�*/�*/�9�9�*/�XE�E�E�E�Errc���eZdZejejdkoed��d���ZdZ	d�Z
d�Zd�Zd�Z
ejejd	kd
��ejed��d�����Zd
S)�TestReadlineiz%not supported in this library versionc�^�tddd���\}}}|�|d��dS)Nz-czimport readlinezxterm-256color)�TERMr)r	r )r%�rc�stdout�stderrs    r�	test_initzTestReadline.test_init�sF��.�d�4E�3C�E�E�E���F�F������%�%�%�%�%rzvimport readline
readline.set_auto_history({})
input()
print("History length:", readline.get_current_history_length())
c��t|j�d����}|�d|��dS)NTsHistory length: 1�r�auto_history_scriptr<�assertIn�r%�outputs  r�test_auto_history_enabledz&TestReadline.test_auto_history_enabled�s=����1�8�8��>�>�?�?��	
�
�
�*�F�3�3�3�3�3rc��t|j�d����}|�d|��dS)NFsHistory length: 0rOrRs  r�test_auto_history_disabledz'TestReadline.test_auto_history_disabled�s=����1�8�8��?�?�@�@��	
�
�
�*�F�3�3�3�3�3rc�|�tjd��}t|d���}|�d|��dS)Na
            import readline
            def complete(text, state):
                if state == 0 and text == "$":
                    return "$complete"
                return None
            if "libedit" in getattr(readline, "__doc__", ""):
                readline.parse_and_bind(r'bind "\t" rl_complete')
            else:
                readline.parse_and_bind(r'"\t": complete')
            readline.set_completer_delims(" \t\n")
            readline.set_completer(complete)
            print(input())
        s$	
)�inputs	$complete)�textwrap�dedentrrQ)r%�scriptrSs   r�test_set_complete_delimsz%TestReadline.test_set_complete_delims�sF����
"�

�

����x�0�0�0���
�
�l�F�+�+�+�+�+rc�L�tjtjd��}|dvr|�d|����	t�d��n<#t$r/}|�dt|��z��Yd}~nd}~wwxYwd}d}|dtd��zz
}|d	z
}|d
z
}|dz
}t||��}|�
d|��|�
d
|��tjdksts|�
d|��tsAttd��r,|�
d|��|�
d|��d}|�
d|zdz|��|�
d|z|��dS)N)�C�POSIXzthe LC_CTYPE locale is uëïr8a*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]'
�darwinsindexes 11 13
�set_pre_input_hookssubstitution 't\xeb'
s matches ['t\xebnt', 't\xebxt']
s'[\xefnserted]|t\xebxt[after]'sresult s
shistory )�locale�	setlocale�LC_CTYPEr;r
rr:r<�lenrrQ�sys�platformrr)r%�locr>r[rXrS�expecteds       r�
test_nonasciizTestReadline.test_nonascii�s�����v���5�5���.� � �
�M�M�;�C�;�;�<�<�<�	L�� � ��,�,�,�,��!�	L�	L�	L��M�M�<�v�c�{�{�J�K�K�K�K�K�K�K�K�����	L����2��h��
��3�y�>�>�)�)��
����
����
�������'�'���
�
�*�F�3�3�3��
�
�@�&�I�I�I��<�8�#�#�;�#��M�M�.��7�7�7��	K�w�x�1E�F�F�	K��M�M�6��?�?�?��M�M�A�6�J�J�J�5���
�
�j�8�+�g�5�v�>�>�>�	
�
�
�k�H�,�f�5�5�5�5�5s�A�
B�"%B�Biz3this readline version does not support history-sizez-editline history size configuration is brokenc	��d}t��5}tj�|d��}t	|d��5}|�d|z��ddd��n#1swxYwYtj�|d��}t	|d��5}d�d�t
|dz��D����}|�|��ddd��n#1swxYwYd	}ttj��}||d
<||d<t|d|�
��t	|d��5}|�
��}	ddd��n#1swxYwY|�t|	��|��|�|	d�
��d��ddd��dS#1swxYwYdS)N�
�inputrc�wbsset history-size %d
�historyrc3� K�|]	}d|zV��
dS)sitem %d
Nr)�.0�is  r�	<genexpr>z1TestReadline.test_history_size.<locals>.<genexpr>*sC���� B� B�$%�!-�q� 0� B� B� B� B� B� Brrz�
import os
import readline

history_file = os.environ["HISTORY_FILE"]
readline.read_history_file(history_file)
input()
readline.write_history_file(history_file)
�INPUTRC�HISTORY_FILEslast input
)rX�env�rb���s
last input)rr2�path�join�open�write�range�dict�environr�	readlinesr rh�strip)
r%�history_size�test_dirrp�f�history_file�datar[ry�liness
          r�test_history_sizezTestReadline.test_history_sizes���
��
�Z�Z�	?�8��g�l�l�8�Y�7�7�G��g�t�$�$�
A�����0�<�?�@�@�@�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A�
A����
A�
A�
A�
A��7�<�<��)�<�<�L��l�D�)�)�
�Q��x�x� B� B�).�|�a�/?�)@�)@� B� B� B�B�B������
�
�
�	
�
�
�
�
�
�
�
�
�
�
����
�
�
�
��F��r�z�"�"�C�$�C�	�N�".�C����F�/�s�;�;�;�;��l�D�)�)�
&�Q����
�
��
&�
&�
&�
&�
&�
&�
&�
&�
&�
&�
&����
&�
&�
&�
&����S��Z�Z��6�6�6����U�2�Y�_�_�.�.�
�>�>�>�?	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?�	?����	?�	?�	?�	?�	?�	?s��1G�A'�G�'A+	�+G�.A+	�/3G�"AC3�'G�3C7	�7G�:C7	�;A
G�E&�G�&E*	�*G�-E*	�.AG�G�GN)r@rArBrD�skipIfr
rrrMrPrTrVr\rmr�rrrrGrG�s��������X�_�X�/�&�8�L��_�<�>�>�&�&�>�>�&���4�4�4�4�4�4�,�,�,�&[6�[6�[6�D�X�_�X�/�%�7�J�L�L��X�_�[�D�F�F�!?�!?�F�F�L�L�!?�!?�!?rrG�__main__)rCrer2rir+rYrD�test.supportr�test.support.import_helperr�test.support.os_helperrrr�test.support.pty_helperr�test.support.script_helperr	r
rrrrrE�TestCaserrGr@�mainrrr�<module>r�s������
�
�
�	�	�	�	�
�
�
�
������������� � � � � � �4�4�4�4�4�4�;�;�;�;�;�;�;�;�;�;�+�+�+�+�+�+�7�7�7�7�7�7��=��$�$��
�7�8�0�1�1�G�%��)K�K�K�K��#�E�	�X�5E�(E�K�	7�	7�	7����W�W�X��7�7�>�?�?�]E�]E�]E�]E�]E�x�0�]E�]E�?�?�]E�@y?�y?�y?�y?�y?�8�$�y?�y?�y?�x�z����H�M�O�O�O�O�O��r

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