ó
šßÈ[c           @   sP   d  Z  d d l Z d d l m Z m Z d „  Z d „  Z d „  Z d „  Z d S(	   sj   
This plugin provides command-line options for controlling whether and how tests
make use of online data.
iÿÿÿÿNi   (   t   turn_off_internett   turn_on_internetc      
   C   sE   |  j  d d d d d d d d d	 ƒ|  j d
 d d d d t ƒd  S(   Ns   --remote-datat   nargst   ?t   constt   anyt   defaultt   nonet   helps   run tests with online datat   remote_data_strictsr   If 'True', tests will fail if they attempt to access the internet but are not explicitly marked with 'remote_data't   typet   bool(   t	   addoptiont   addinit   False(   t   parser(    (    sN   lib/python2.7/site-packages/astropy/extern/plugins/pytest_remotedata/plugin.pyt   pytest_addoption
   s    c         C   sÚ   |  j  d ƒ j d ƒ |  j  d ƒ j d ƒ t |  j  d ƒ ƒ } |  j d ƒ } | d k rw t j d
 j | ƒ ƒ ‚ n  | rÖ | d k r¥ t d |  j j	 d t
 ƒ qÖ | d k rÖ t d |  j j	 d | d k ƒ qÖ n  d  S(   Nt   markerssA   remote_data: Apply to tests that require data from remote serverssT   internet_off: Apply to tests that should only run when network access is deactivatedR	   t   remote_datat   astropyR   t   githubR   s*   '{}' is not a valid source for remote datat   verboset   allow_github_datat   allow_astropy_data(   R   R   R   R   (   t   getinit   appendR   t	   getoptiont   pytestt
   UsageErrort   formatR    t   optionR   t   True(   t   configt   strict_checkR   (    (    sN   lib/python2.7/site-packages/astropy/extern/plugins/pytest_remotedata/plugin.pyt   pytest_configure   s"    c           C   s   t  ƒ  d S(   s   
    Cleanup post-testing
    N(   R   (    (    (    sN   lib/python2.7/site-packages/astropy/extern/plugins/pytest_remotedata/plugin.pyt   pytest_unconfigure4   s    c         C   s\  |  j  d ƒ } |  j  d ƒ } |  j j d ƒ } | d  k	 rW | d  k	 rW t d ƒ ‚ n  | d  k	 r-t | j ƒ d k rˆ | j d } n | j j d d ƒ } | d k r¸ t d	 ƒ ‚ n  | d
 k rÔ t	 j
 d ƒ q-| d k rÿ | d k r*t	 j
 d ƒ q*q-| d k r-| d k r*t	 j
 d ƒ q*q-n  | d  k	 rX| d
 k rXt	 j
 d ƒ qXn  d  S(   NR   t   internet_offs/   remote_data and internet_off are not compatiblei    t   sourceR   R   R   s.   source should be 'astropy', 'any', or 'github'R   s    need --remote-data option to runs9   need --remote-data or --remote-data=astropy option to runs2   run this test only when network access is disabled(   R   R   R   (   R   R   (   t
   get_markerR    t   getvaluet   Nonet
   ValueErrort   lent   argst   kwargst   getR   t   skip(   t   itemR   R$   t   remote_data_configR%   (    (    sN   lib/python2.7/site-packages/astropy/extern/plugins/pytest_remotedata/plugin.pyt   pytest_runtest_setup>   s,    (	   t   __doc__R   t   disable_internetR    R   R   R"   R#   R1   (    (    (    sN   lib/python2.7/site-packages/astropy/extern/plugins/pytest_remotedata/plugin.pyt   <module>   s   			
