U
    Kvf                     @   s`   d dl mZ d dlmZ d dlZd dlZd dlZd dlmZ d dl	m
Z
mZ dd Zdd	 ZdS )
    )lrange)BytesION)assert_equal)load_picklesave_picklec               	   C   s   t jdd} td}| d }t|| t|}t|| t| d }t|| t|}t|| z"t	| t	| t
|  W n ttfk
r   Y nX tj| rtt }t|| |dd t|}|  t|| d S )Npickleprefix
   z/res.pklres2.pklr   )tempfilemkdtempr   r   r   r   pathlibPathosremovermdirOSErrorIOErrorpathexistsAssertionErrorr   seekclose)tmpdiraZpath_strbpath_pathlibcfhd r!   G/tmp/pip-unpacked-wheel-2v6byqio/statsmodels/iolib/tests/test_pickle.pytest_pickle   s.    






r#   c                  C   sT   t jdd} td}G dd d}|| tj d }t|| t|}t|| d S )Nr   r   r
   c                   @   s   e Zd Zdd ZdddZdS )	z*test_pickle_supports_open.<locals>.SubPathc                 S   s   t || _d S )N)r   r   _path)selfr   r!   r!   r"   __init__4   s    z3test_pickle_supports_open.<locals>.SubPath.__init__rNc                 S   s   | j j|||||dS )N)mode	bufferingencodingerrorsnewline)r$   open)r%   r)   r*   r+   r,   r-   r!   r!   r"   r.   7   s    z/test_pickle_supports_open.<locals>.SubPath.open)r'   r(   NNN)__name__
__module____qualname__r&   r.   r!   r!   r!   r"   SubPath3   s        r2   r   )r   r   r   r   pathsepr   r   r   )r   r   r2   r   r   r!   r!   r"   test_pickle_supports_open/   s    
r4   )Zstatsmodels.compat.pythonr   ior   r   r   r   Znumpy.testingr   Zstatsmodels.iolib.smpickler   r   r#   r4   r!   r!   r!   r"   <module>   s   "