File: //usr/local/lib/python3.10/test/__pycache__/test_readline.cpython-310.pyc
o
�i�8 � @ s d Z ddlmZ ddlmZ ddlZddlZddlZddlZddl Z ddl
Z
ddlZddlm
Z
ddlmZ ddlmZmZmZ ddlmZ ed �Zeed
�rUdejv Znej o\dej v Zd
d� Ze�eed�d�G dd� dej��ZG dd� dej�Zddd�Ze dkr�e�!� dS dS )z:
Very minimal unittests for parts of the readline module.
� )� ExitStack)�EION)�verbose)�
import_module)�unlink�temp_dir�TESTFN)�assert_python_ok�readline�_READLINE_LIBRARY_VERSIONzEditLine wrapper�libeditc C sb t r/ttd�rtdtjd��� tdtjd��� ttd�r&tdtj��� tdt� �� d S d S )N�_READLINE_VERSIONzreadline version: z#xzreadline runtime version: r zreadline library version: zuse libedit emulation? )r �hasattrr
�printr
Z_READLINE_RUNTIME_VERSIONr �is_editline� r r �//usr/local/lib/python3.10/test/test_readline.py�setUpModule s
�r �
clear_historyzXThe history update test cannot be run because the clear_history method is not available.c @ s: e Zd ZdZdd� Ze�eed�d�dd� �Z dd � Z
d
S )�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 C s� 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� d S )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)�selfr r r �testHistoryUpdates1 s
z*TestHistoryManipulation.testHistoryUpdates�append_history_filezappend_history not availablec C sL t jdd�}|�� |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�|� zt�d|� W n ty� Y nw t�|� t� |� d S ) NF)�deleter r r r r � )�tempfile�NamedTemporaryFile�close�name�
addCleanupr r
r r �write_history_filer r �read_history_filer r! �os�FileNotFoundError)r ZhfileZ hfilenamer r r �test_write_read_appendH s:
�
z.TestHistoryManipulation.test_write_read_appendc
C s� t �� zt �d� W n ty& } z| �dt|� � W Y d }~nd }~ww t �d� t �dd� t �t� | � t
jt� t �� t �t� t
rNt �d� | �t �d�d� | �t �d�d� d S )Nu entrée 1� Locale cannot encode test data: u entrée 2r u
entrée 22Zdummyr )r
r r �UnicodeEncodeError�skipTest�formatr r) r r( r+ �remover* r r r )r �errr r r �test_nonascii_historyv s"