ó
\K]c           @   sÒ   d  d l  Z  d  d l Z d  d l Z d d l m Z m Z m Z d  d l m Z y d  d l	 Z	 e
 Z Wn e k
 r e Z n Xd Z e j e e ƒ Z e d e f d „  ƒ  Yƒ Z e d k rÎ e j ƒ  n  d S(	   iÿÿÿÿNi   (   t   TestCaset   temp_directoryt   override_env_config(   t   configs*   pyyaml needed for configuration file testst
   TestConfigc           B   sM   e  Z e Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   c         C   s&   t  d ƒ |  _ t t |  ƒ j ƒ  d  S(   Nt
   config_tmp(   R   t   tmppatht   superR   t   setUp(   t   self(    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyR      s    c         C   s   t  j d |  j ƒ S(   sT   
        Creates a mock launch location.
        Returns the location path.
        t   dir(   t   tempfilet   mkdtempR   (   R	   (    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyt   mock_cfg_location   s    c      	   C   sJ   t  j j | t j ƒ } t | d ƒ  } t j | | d t ƒWd QXd S(   s<   
        Injects a mock configuration at 'location'
        t   wtt   default_flow_styleN(	   t   ost   patht   joinR   t   _config_fnamet   opent   yamlt   dumpt   False(   R	   t   locationt   cfgt   tmpcfgt   f(    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyt   inject_mock_cfg#   s    c         C   sF   t  ƒ  } x6 t t ƒ D]( } | j ƒ  r t t | ƒ | | <q q W| S(   s8   
        Gets the current numba config settings
        (   t   dictR
   R   t   isuppert   getattr(   R	   t   storet   x(    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyt   get_settings+   s
    	c         C   s˜   t  j ƒ  } |  j ƒ  } t  j | ƒ t d d ƒ  |  j ƒ  } Wd QX|  j | | ƒ z& t d d ƒ  |  j ƒ  } Wd QXWd t  j | ƒ X| | f S(   s×   
        Returns a config "original" from a location with no config file
        and then the impact of applying the supplied cfg dictionary as
        a config file at a location in the returned "current".
        t   _N(   R   t   getcwdR   t   chdirR   R"   R   (   R	   R   t   original_cwdt
   launch_dirt   originalt   current(    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyt   create_config_effect5   s    c         C   sµ   d } x¨ t  j t  j g D]” } |  j i d | | ƒ 6ƒ \ } } |  j | | k ƒ |  j | | | | k ƒ |  j | | d ƒ | j | ƒ | j | ƒ |  j | | ƒ q Wd  S(   Nt   COLOR_SCHEMEt   light_bg(   t   strt   uppert   lowerR*   t
   assertTruet   assertEqualt   pop(   R	   t   keyt   caset   origt   curr(    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyt   test_configV   s    "c         C   s)   |  j  i  ƒ \ } } |  j | | ƒ d  S(   N(   R*   R1   (   R	   R5   R6   (    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyt   test_empty_configd   s    (   t   __name__t
   __module__R   t   _numba_parallel_test_R   R   R   R"   R*   R7   R8   (    (    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyR      s   				
	!	t   __main__(   R   R   t   unittestt   supportR    R   R   t   numbaR   R   t   Truet
   _HAVE_YAMLt   ImportErrorR   t	   _skip_msgt   skipIft
   needs_yamlR   R9   t   main(    (    (    s6   lib/python2.7/site-packages/numba/tests/test_config.pyt   <module>   s   

X