File: //lib64/python3.6/test/__pycache__/test_readline.cpython-36.pyc
3
\1 � @ s� d Z ddlmZ ddlmZ ddlZddlZddlZddlZddl Z ddl
Z
ddlZddlm
Z
mZmZmZ ddlmZ e
d�Zej o�dej kZejeed �d
�G dd� dej��ZG d
d� dej�Zddd�Zedkr�ej� dS )z:
Very minimal unittests for parts of the readline module.
� )� ExitStack)�EION)�
import_module�unlink�temp_dir�TESTFN)�assert_python_ok�readline�libedit�
clear_historyzXThe history update test cannot be run because the clear_history method is not available.c @ s: e Zd ZdZdd� Zejeed�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 j� t jd� t jd� | jt jd�d � | jt jd�d� | jt jd�d� t jdd� | jt jd�d � | jt jd�d� | jt jd�d� | jt j� d� t jd� | jt jd�d � | jt jd�d� | jt j� 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)�self� r �%/usr/lib64/python3.6/test_readline.py�testHistoryUpdates s
z*TestHistoryManipulation.testHistoryUpdates�append_history_filezappend_history not availablec
C s@ t jdd�}|j� |j}| jt|� tj� tjd� tjd� tj |� tj� | j
tj� d� tj|� | j
tj� d� | j
tj
d�d� | j
tj
d�d� tjd|� tj� tj|� | j
tj� d� | j
tj
d�d� | j
tj
d�d� | j
tj
d�d� tj|� | jt�� tjd|� W d Q R X tj |� 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_append6 s2
z.TestHistoryManipulation.test_write_read_appendc C s� t j� yt jd� W n4 tk
rJ } z| jdt|� � W Y d d }~X nX t jd� t jdd� t jt� | j t
jt� t j� t jt� t
r�t jd� | jt jd�d� | jt jd�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 r r r! �remover �is_editliner r )r �errr r r �test_nonascii_history] s $
z-TestHistoryManipulation.test_nonascii_historyN)�__name__�
__module__�__qualname__�__doc__r �unittest�
skipUnless�hasattrr r# r* r r r r r s
&r c @ sn e Zd Zejejdk oe d�dd� �ZdZ dd� Z
dd � Zd
d� Zejejdk d
�ejed�dd� ��Z
dS )�TestReadlinei z%not supported in this library versionc C s$ t dddd�\}}}| j|d� d S )Nz-czimport readlinezxterm-256color)ZTERM� )r r )r Zrc�stdout�stderrr r r � test_inits s zTestReadline.test_initzvimport readline
readline.set_auto_history({})
input()
print("History length:", readline.get_current_history_length())
c C s t | jjd��}| jd|� d S )NTs History length: 1
)�run_pty�auto_history_scriptr&