File: //usr/local/lib/python3.7/test/__pycache__/test_readline.cpython-37.pyc
B
��g�3 � @ s d Z ddlmZ ddlmZ ddlZddlZddlZddlZddl Z ddl
Z
ddlZddlm
Z
mZmZmZmZ ddlmZ e
d�Zeed�r�d ejkZnej o�d
ej kZdd� Ze�eed
�d�G dd� dej��ZG dd� dej�Zddd�Zedk�re�� dS )z:
Very minimal unittests for parts of the readline module.
� )� ExitStack)�EION)�
import_module�unlink�temp_dir�TESTFN�verbose)�assert_python_ok�readline�_READLINE_LIBRARY_VERSIONzEditLine wrapper�libeditc C s^ t rZttd�r2tdtjd��� tdtjd��� ttd�rLtdtj��� tdt� �� 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.7/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 )Nz
first linezsecond liner � � z
replaced line)r
r �add_history�assertEqual�get_history_item�replace_history_item�get_current_history_lengthZremove_history_item)�selfr r r �testHistoryUpdates/ s
z*TestHistoryManipulation.testHistoryUpdates�append_history_filezappend_history not availablec C s@ 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�|� | �t�� t�d|� W d Q R X t� |� d S ) NF)�deletez
first linezsecond liner r r � )�tempfileZNamedTemporaryFile�close�name�
addCleanupr r
r r �write_history_filer r �read_history_filer r �osZassertRaises�FileNotFoundError)r ZhfileZ hfilenamer r r �test_write_read_appendF s2
z.TestHistoryManipulation.test_write_read_appendc
C s� t �� yt �d� W n4 tk
rJ } z| �dt|� � W d d }~X Y nX t �d� t �dd� t �t� | � t
jt� t �� t �t� t
r�t �d� | �t �d�d� | �t �d�d� d S )Nu entrée 1z Locale cannot encode test data: u entrée 2r u
entrée 22Zdummyr )r
r r �UnicodeEncodeError�skipTest�formatr r&