ó
ÓnùWc           @   s»   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z	 d d l m
 Z
 m Z d „  Z d e j f d „  ƒ  YZ e d k r· e j ƒ  n  d S(   s   develop tests
iÿÿÿÿN(   t   DirectorySandboxt   SandboxViolationc          C   s?   t  j j d ƒ s t Sy t d ƒ }  Wn t k
 r: t SXt S(   sp   
    Run this to determine if the local machine has win32com, and if it
    does, include additional tests.
    t   win32t   win32com(   t   syst   platformt
   startswitht   Falset
   __import__t   ImportErrort   True(   t   mod(    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   has_win32com   s    t   TestSandboxc           B   sV   e  Z d  „  Z d „  Z d „  Z d „  Z e e ƒ Z e ƒ  rK d „  Z n  d „  Z	 RS(   c         C   s   t  j ƒ  |  _ d  S(   N(   t   tempfilet   mkdtempt   dir(   t   self(    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   setUp   s    c         C   s   t  j |  j ƒ d  S(   N(   t   shutilt   rmtreeR   (   R   (    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   tearDown    s    c         C   s?   t  j d k  r d  St |  j ƒ } | j |  j t j ƒ ƒ d  S(   Ns   2.4(   R   t   versionR    R   t   runt   _file_writert   ost   devnull(   R   t   sandbox(    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   test_devnull#   s    c            s   ‡  f d †  } | S(   Nc             s*   t  ˆ  d ƒ }  |  j d ƒ |  j ƒ  d  S(   Nt   wt   xxx(   t   opent   writet   close(   t   f(   t   path(    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   do_write*   s    (    (   R#   R$   (    (   R#   sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyR   )   s    c         C   s¢   d d l  } | j } t j j | d ƒ } t |  j ƒ } z? y | j |  j | ƒ ƒ Wn t	 k
 rv |  j
 d ƒ n XWd t j j | ƒ r t j | ƒ n  Xd S(   sm   
            win32com should not be prevented from caching COM interfaces
            in gen_py.
            iÿÿÿÿNt
   test_writes4   Could not create gen_py file due to SandboxViolation(   R   t   __gen_path__R   R#   t   joinR    R   R   R   R   t   failt   existst   remove(   R   R   t   gen_pyt   targetR   (    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   test_win32com3   s    	 c         C   sS   t  j t d ƒ } t j d ƒ } t j j | t | ƒ ƒ | j	 d k sO t
 ‚ d S(   sT   
        It should be possible to execute a setup.py with a Byte Order Mark
        s   script-with-bom.pyt	   namespacet   passedN(   t   pkg_resourcest   resource_filenamet   __name__t   typest
   ModuleTypet
   setuptoolsR   t   execfilet   varst   resultt   AssertionError(   R   R,   R.   (    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   test_setup_py_with_BOMD   s
    		(
   R2   t
   __module__R   R   R   R   t   staticmethodR   R-   R:   (    (    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyR      s   					t   __main__(   t   __doc__R   R   R   t   unittestR   R3   R0   t   setuptools.sandboxR5   R    R   R   t   TestCaseR   R2   t   main(    (    (    sD   /var/www/html/venv/build/setuptools/setuptools/tests/test_sandbox.pyt   <module>   s   	3