B
    q\                 @   s   d Z ddlZddlZddlZddlZddlmZ ddlZddlm	Z	m
Z
 ddlmZ ddlmZ ddlmZ dd Zd	d
 Zdd Zdd ZdS )z[
This plugin provides customization of configuration and cache directories used
by pytest.
    N)OrderedDict)set_temp_configset_temp_cache)writeable_directory) treat_deprecations_as_exceptionsc             C   sH   | j ddtdd | j ddtdd | jddd d | jd	dd d d S )
Nz--astropy-config-dir?a  specify directory for storing and retrieving the Astropy configuration during tests (default is to use a temporary directory created by the test runner); be aware that using an Astropy config file other than the default can cause some tests to fail unexpectedly)nargstypehelpz--astropy-cache-dirzspecify directory for storing and retrieving the Astropy cache during tests (default is to use a temporary directory created by the test runner)astropy_config_dir)defaultastropy_cache_dir)Z	addoptionr   Zaddini)parser r   ;lib/python3.7/site-packages/astropy/tests/plugins/config.pypytest_addoption   s    

r   c             C   s
   t   d S )N)r   )configr   r   r   pytest_configure5   s    r   c             C   sl   | j d}| j d}| j dp&|}| j dp6|}|rPt|| _| j  |rht|| _| j  d S )Nr   r   )r   ZgetiniZ	getoptionr   	__enter__r   )itemZ
config_dirZ	cache_dirr   r   r   pytest_runtest_setup8   s    


r   c             C   s,   t | dr| j  t | dr(| j  d S )Nr   r   )hasattrr   __exit__r   )r   Znextitemr   r   r   pytest_runtest_teardownI   s    


r   )__doc__ZdatetimeZlocaleossyscollectionsr   ZpytestZastropy.config.pathsr   r   Zastropy.utils.argparser   Zastropy.tests.helperr   importlib.machinery	machineryZimportlib_machineryr   r   r   r   r   r   r   r   <module>   s   