3
Ud	              	   @   s   d dl Z d dlZd dlmZ G dd dZejjdddgddggdd	 Zejjd
ee	dgdd Z
ejjdddgde jgedgee jge	dge	e jggdd ZdS )    N)detect_console_encodingc                   s8   e Zd ZdZ fddZedd Zedd Z  Z	S )MockEncodingz
    Used to add a side effect when accessing the 'encoding' property. If the
    side effect is a str in nature, the value will be returned. Otherwise, the
    side effect should be an exception that will be raised.
    c                s   t  j  || _d S )N)super__init__val)selfencoding)	__class__ X/var/www/html/virt/lib64/python3.6/site-packages/pandas/tests/io/formats/test_console.pyr      s    
zMockEncoding.__init__c             C   s   | j | jS )N)raise_or_returnr   )r   r
   r
   r   r      s    zMockEncoding.encodingc             C   s   t | tr| S | d S )N)
isinstancestr)r   r
   r
   r   r      s    
zMockEncoding.raise_or_return)
__name__
__module____qualname____doc__r   propertyr   staticmethodr   __classcell__r
   r
   )r	   r   r      s   r   zempty,filledstdinstdoutc             C   sR   | j  @}|jd| td |jd| t| t |ksDtW d Q R X d S )Nzsys. )contextsetattrr   r   AssertionError)monkeypatchemptyZfilledr   r
   r
   r   .test_detect_console_encoding_from_stdout_stdin   s    
r   r   asciic             C   sF   | j  4}|jddd  |jdt| t dks8tW d Q R X d S )Nzlocale.getpreferredencodingc               S   s   dS )Nfoor
   r
   r
   r
   r   <lambda>.   s    zAtest_detect_console_encoding_fallback_to_locale.<locals>.<lambda>z
sys.stdoutr    )r   r   r   r   r   )r   r   r   r
   r
   r   /test_detect_console_encoding_fallback_to_locale*   s    
r"   z
std,localec                sZ   | j  H}|jd fdd |jdt| |jddd  t dksLtW d Q R X d S )Nzlocale.getpreferredencodingc                  s
   t j S )N)r   r   r
   )localer
   r   r!   D   s    zBtest_detect_console_encoding_fallback_to_default.<locals>.<lambda>z
sys.stdoutzsys.getdefaultencodingc               S   s   dS )NsysDefaultEncodingr
   r
   r
   r
   r   r!   G   s    r$   )r   r   r   r   r   )r   Zstdr#   r   r
   )r#   r   0test_detect_console_encoding_fallback_to_default3   s    
r%   )r#   ZpytestZpandas._configr   r   markZparametrizer   AttributeErrorIOErrorr"   Errorr%   r
   r
   r
   r   <module>   s   "	