U
    +if{	                  
   @   s   d dl Z d dlZd dlmZ G dd dZejdddgddggdd	 Zejd
ee	dgdd Z
e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    || _d S N)super__init__val)selfencoding	__class__ W/home/mars/bis/venv/lib/python3.8/site-packages/pandas/tests/io/formats/test_console.pyr      s    
zMockEncoding.__init__c                 C   s   |  | jS r   )raise_or_returnr   )r   r   r   r   r	      s    zMockEncoding.encodingc                 C   s   t | tr| S | d S r   )
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   |   @}|d| td |d| t| t |ksDtW 5 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   |   4}|ddd  |dt| t dks8tW 5 Q R X d S )Nlocale.getpreferredencodingc                   S   s   dS )Nfoor   r   r   r   r   <lambda>.       zAtest_detect_console_encoding_fallback_to_locale.<locals>.<lambda>
sys.stdoutr$   r   )r   r	   r   r   r   r   /test_detect_console_encoding_fallback_to_locale*   s    
r(   z
std,localec              	      sZ   |   H}|d fdd |dt| |ddd  t dksLtW 5 Q R X d S )Nr#   c                      s
   t  S r   )r   r   r   localer   r   r%   D   r&   zBtest_detect_console_encoding_fallback_to_default.<locals>.<lambda>r'   zsys.getdefaultencodingc                   S   s   dS )NsysDefaultEncodingr   r   r   r   r   r%   G   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OSErrorr(   Errorr,   r   r   r   r   <module>   s$   


