Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_readline.cpython-312.opt-1.pyc

�

'Μg�=����dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
mZddlmZddlmZddlmZe
d	�Zeed
�rdej.vZnejxrdejvZd
�Zej4eed�d�Gd�dej6��ZGd�dej6�Zedk(rej>�yy)z:
Very minimal unittests for parts of the readline module.
�N)�verbose)�
import_module)�unlink�temp_dir�TESTFN)�run_pty)�assert_python_ok)�requires_working_threading�readline�_READLINE_LIBRARY_VERSIONzEditLine wrapper�libeditc�"�tr�ttd�r:tdtjd���tdtj
d���ttd�rtdtj���tdt���yy)N�_READLINE_VERSIONzreadline version: z#xzreadline runtime version: rzreadline library version: zuse libedit emulation? )r�hasattrr�printr�_READLINE_RUNTIME_VERSIONr�is_editline���//usr/local/lib/python3.12/test/test_readline.py�setUpModulers|����8�0�1��&�x�'A�'A�"�&E�F�G��.�x�/Q�/Q�RT�.U�V�W��8�8�9��.�x�/Q�/Q�.T�U�V�
�'��}�5�6�r�
clear_historyzXThe history update test cannot be run because the clear_history method is not available.c�b�eZdZdZd�Zejeed�d�d��Z	d�Z
d�Zy)	�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��tj�tjd�tjd�|jtj	d�d�|jtj	d�d�|jtj	d�d�tjdd�|jtj	d�d�|jtj	d�d�|jtj	d�d�|jtj
�d�tjd�|jtj	d�d�|jtj	d�d�|jtj
�d�y)N�
first line�second liner��z
replaced line)rr�add_history�assertEqual�get_history_item�replace_history_item�get_current_history_length�remove_history_item)�selfs r�testHistoryUpdatesz*TestHistoryManipulation.testHistoryUpdates0sR����� ����\�*����]�+�����2�2�1�5�t�<�����2�2�1�5�|�D�����2�2�1�5�}�E��%�%�a��9�����2�2�1�5�t�<�����2�2�1�5��G�����2�2�1�5�}�E�����<�<�>��B��$�$�Q�'�����2�2�1�5�t�<�����2�2�1�5�}�E�����<�<�>��Br�append_history_filezappend_history not availablec��tjd��}|j�|j}|j	t
|�tj�tjd�tjd�tj|�tj�|jtj�d�tj|�|jtj�d�|jtjd�d�|jtjd�d�tjd|�tj�tj|�|jtj�d�|jtjd�d�|jtjd�d�|jtjd�d�tj
|�	tjd|�tj
|�tj|�y#t $rY�!wxYw)	NF)�deleterrrrr�)�tempfile�NamedTemporaryFile�close�name�
addCleanuprrrr �write_history_filer!r$�read_history_filer"r(�os�FileNotFoundError)r&�hfile�	hfilenames   r�test_write_read_appendz.TestHistoryManipulation.test_write_read_appendGs����+�+�5�9��
���
��J�J�	�����	�*�	��� ����\�*����]�+��#�#�I�.���� �����<�<�>��B��"�"�9�-�����<�<�>��B�����2�2�1�5�|�D�����2�2�1�5�}�E�	�$�$�Q�	�2���� ��"�"�9�-�����<�<�>��B�����2�2�1�5�|�D�����2�2�1�5�}�E�����2�2�1�5�}�E�	�	�	�)��	!��(�(��I�6�
�I�I�i� �	�#�#�I�.��!�	��	�s�?J�	J�Jc��tj�	tjd�tjd�tj
dd�tjt�|jtjt�tj�tjt�trtjd�|jtjd�d�|jtjd�d�y#t$r(}|j	dt|�z�Yd}~��'d}~wwxYw)Nu	entrée 1� Locale cannot encode test data: u	entrée 2ru
entrée 22�dummyr)rrr �UnicodeEncodeError�skipTest�formatr#r1rr0r3�remover2rr!r")r&�errs  r�test_nonascii_historyz-TestHistoryManipulation.test_nonascii_historyus������ �	L�� � ��-�	���[�)��%�%�a��6��#�#�F�+�����	�	�6�*���� ��"�"�6�*��
� � ��)�����2�2�1�5�{�C�����2�2�1�5�|�D��"�	L��M�M�<�v�c�{�J�K�K��	L�s�D&�&	E�/E�Ec��tj�}|jtj|�tj	�tjd�tjd�tjd�tjd�|j
tj�d�tjt�|jtjt�tj	�|j
tj�d�|j
tj�d�tjt�|j
tjd�d�|j
tjd�d�|j
tjd�d�|jtj�d�y)	Nrr�
third linerrrr+)rr+)r�get_history_lengthr0�set_history_lengthrr r!r1rr3r>r$r2r"�assertIn�r&�previous_lengths  r�test_write_read_limited_historyz7TestHistoryManipulation.test_write_read_limited_history�sW��"�5�5�7������3�3�_�E���� ����\�*����]�+����\�*��#�#�A�&�����4�4�6��:��#�#�F�+�����	�	�6�*���� �����<�<�>��B�����4�4�6��:��"�"�6�*�����2�2�1�5�}�E�����2�2�1�5�|�D�����2�2�1�5�t�<�	
�
�
�h�9�9�;�V�DrN)�__name__�
__module__�__qualname__�__doc__r'�unittest�
skipUnlessrrr7r@rHrrrrr&sH���C�.�X�����+@�A�7�9�*/�9�*/�XE�&Errc��eZdZejejdkxred�d��ZdZ	d�Z
d�Zd�Zd�Z
ejejd	kd
�ejed�d���Ze�d
��Zd�Zy)�TestReadlineiz%not supported in this library versionc�L�tddd��\}}}|j|d�y)Nz-czimport readlinezxterm-256color)�TERMr)r	r!)r&�rc�stdout�stderrs    r�	test_initzTestReadline.test_init�s.��.�d�4E�3C�E���F�F������%rzvimport readline
readline.set_auto_history({})
input()
print("History length:", readline.get_current_history_length())
c�p�t|jjd��}|jd|�y)NTsHistory length: 1�r�auto_history_scriptr=rE�r&�outputs  r�test_auto_history_enabledz&TestReadline.test_auto_history_enabled�s.����1�1�8�8��>�?��	
�
�
�*�F�3rc�p�t|jjd��}|jd|�y)NFsHistory length: 0rXrZs  r�test_auto_history_disabledz'TestReadline.test_auto_history_disabled�s.����1�1�8�8��?�@��	
�
�
�*�F�3rc�l�tjd�}t|d��}|jd|�y)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�dedentrrE�r&�scriptr[s   r�test_set_complete_delimsz%TestReadline.test_set_complete_delims�s1�����
"�

����x�0���
�
�l�F�+rc���tjtjd�}|dvr|jd|���	tjd�d}d}|dtd�zz
}|d	z
}|d
z
}|dz
}t||�}|jd|�|jd
|�tjdk(sts|jd|�ts4ttd�r$|jd|�|jd|�d}|jd|zdz|�|jd|z|�y#t$r(}|jdt|�z�Yd}~��d}~wwxYw)N)�C�POSIXzthe LC_CTYPE locale is uëïr9a*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<rr r;r=�lenrrE�sys�platformrr)r&�locr?rfrar[�expecteds       r�
test_nonasciizTestReadline.test_nonascii�s\�����v����5���.� �
�M�M�3�C�7�;�<�	L�� � ��,�2��h��
��3�y�>�)�)��
����
����
�������'���
�
�*�F�3��
�
�@�&�I��<�<�8�#�;��M�M�.��7��w�x�1E�F��M�M�6��?��M�M�A�6�J�5���
�
�j�8�+�g�5�v�>�	
�
�
�k�H�,�f�5��c"�	L��M�M�<�v�c�{�J�K�K��	L�s�D<�<	E-�E(�(E-iz3this readline version does not support history-sizez-editline history size configuration is brokenc	�"�d}t�5}tjj|d�}t	|d�5}|jd|z�ddd�tjj|d�}t	|d�5}djd�t
|dz�D��}|j|�ddd�d	}ttj�}||d
<||d<t|d|�
�t	|d�5}|j�}	ddd�|jt	�|�|j|	dj�d�ddd�y#1swY��xYw#1swY��xYw#1swY�ixYw#1swYyxYw)N�
�inputrc�wbsset history-size %d
�historyrc3�&K�|]	}d|z���y�w)sitem %d
Nr)�.0�is  r�	<genexpr>z1TestReadline.test_history_size.<locals>.<genexpr>Es���� B�)@�A�!-�q� 0�)@�s�rz�
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
)ra�env�rb���s
last input)rr3�path�join�open�write�range�dict�environr�	readlinesr!rs�strip)
r&�history_size�test_dirr{�f�history_file�datarfr��liness
          r�test_history_sizezTestReadline.test_history_size7sJ��
��
�Z�8��g�g�l�l�8�Y�7�G��g�t�$�����0�<�?�@�%��7�7�<�<��)�<�L��l�D�)�Q��x�x� B�).�|�a�/?�)@� B�B������
�	*��F��r�z�z�"�C�$�C�	�N�".�C����F�/�s�;��l�D�)�Q����
��*����S��Z��6����U�2�Y�_�_�.�
�>�?�Z�$�$��*�)��,*�)��9�Z�sT�-F�E �4F�6E-�9AF�E9�AF� E*	�%F�-E6	�2F�9F	�>F�Fc�l�tjd�}t|d��}|jd|�y)z7gh-123321: readline should be thread-safe and not crasha�
            import threading
            from test.support.threading_helper import join_thread

            def func():
                input()

            thread1 = threading.Thread(target=func)
            thread2 = threading.Thread(target=func)
            thread1.start()
            thread2.start()
            join_thread(thread1)
            join_thread(thread2)
            print("done")
        sinput1
input2
r`sdoneNrbres   r�test_gh123321_threadsafez%TestReadline.test_gh123321_threadsafe^s4�����"�
�� ��':�;���
�
�g�v�&rc��tj�}|jtj|�tj	d�tj	d�tj	d�tjd�|jtj�d�tj
t�|jtjt�tjt�y)NrrrBr)rrCr0rDr r!r1rr3r>r2rFs  rrHz,TestReadline.test_write_read_limited_historyvs���"�5�5�7������3�3�_�E����\�*����]�+����\�*��#�#�A�&�����4�4�6��:��#�#�F�+�����	�	�6�*��"�"�6�*rN)rIrJrKrM�skipIfrrrrVrYr\r^rgrxr�r
r�rHrrrrPrP�s����X�_�_�X�/�/�&�8�L��_�<�>�&�>�&���4�4�,�&[6�D�X�_�_�X�/�/�%�7�J�L��X�_�_�[�D�F�!?�F�L�!?�F �!�'�"�'�.
+rrP�__main__) rLrpr3rtr,rcrM�test.supportr�test.support.import_helperr�test.support.os_helperrrr�test.support.pty_helperr�test.support.script_helperr	�test.support.threading_helperr
rrrrrrN�TestCaserrPrI�mainrrr�<module>r�s�����	�
���� �4�;�;�+�7�D���$��
�8�0�1�%��)K�)K�K�K��#�#�E�	�X�5E�5E�(E�K�	7�����W�X��7�>�?�wE�x�0�0�wE�?�wE�t`+�8�$�$�`+�P�z���H�M�M�O�r

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