B
    `                 @   s   d dl mZmZmZ eZd dlZyd dlT W n> ek
rj   yd dl	T W n ek
rd   e
d Y nX Y nX ejdkrejdk rdadd Zdd
dZdS )    )absolute_importdivisionprint_functionN)*z=You need the mock library installed on python2.x to run tests)   )r      r   c             #   sp   t | trdnd  fdd|  D }|d  krD|d d }n|d d d |d< x|D ]
}|V  q^W d S )N   

c                s   g | ]}|  qS  r
   ).0l)sepr
   d/home/dcms/DCMS/lib/python3.7/site-packages/ansible_collections/cisco/nxos/tests/unit/compat/mock.py
<listcomp>8   s    z&_iterate_read_data.<locals>.<listcomp>)
isinstancebytessplit)	read_dataZdata_as_listliner
   )r   r   _iterate_read_data3   s    
r    c                s    fdd} fdd} fdd}t dkr^ddl}ttt|jtt|ja | dkrrtd	t	d
} tt dj
_t dj_dj_dj_dj_|j_| j_|j_| _| S )a  
        A helper function to create a mock to replace the use of `open`. It works
        for `open` called directly or used as a context manager.

        The `mock` argument is the mock object to configure. If `None` (the
        default) then a `MagicMock` will be created for you, with the API limited
        to methods or attributes available on standard file handles.

        `read_data` is a string for the `read` methoddline`, and `readlines` of the
        file handle to return.  This is an empty string by default.
        c                 s   j jd k	rj jS t S )N)	readlinesreturn_valuelist)argskwargs)_datahandler
   r   _readlines_side_effectT   s    z)mock_open.<locals>._readlines_side_effectc                 s$   j jd k	rj jS t  S )N)readr   typejoin)r   r   )r   r   r   r
   r   _read_side_effectY   s    z$mock_open.<locals>._read_side_effectc              3   s4   j jd k	rxj jV  qW x D ]
} | V  q"W d S )N)readliner   )r   )r   r   r
   r   _readline_side_effect^   s
    
z(mock_open.<locals>._readline_side_effectNr   open)namespec)r(   )	file_spec_ior   setdirTextIOWrapperunionBytesIOZ	MagicMockr&   	__enter__r   r   writer    r$   r   Zside_effect)mockr   r   r#   r%   r*   r
   )r   r   r   r   	mock_openG   s*     

r3   )Nr   )
__future__r   r   r   r!   __metaclass__sysZunittest.mockImportErrorr2   printversion_infor)   r   r3   r
   r
   r
   r   <module>   s   