ó
Š]c           @   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 m Z d d l	 m
 Z
 d d l m Z d d l m Z d e j e j e j f d	 „  ƒ  YZ d
 „  Z e d k rÐ e e ƒ  ƒ n  d S(   s%   Tests for distutils.command.build_py.iÿÿÿÿN(   t   build_py(   t   Distribution(   t   DistutilsFileError(   t   support(   t   run_unittestt   BuildPyTestCasec           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   së  |  j  ƒ  } t t j j | d ƒ d ƒ } z | j d ƒ Wd  | j ƒ  Xt t j j | d ƒ d ƒ } z | j d ƒ Wd  | j ƒ  X|  j  ƒ  } t i d g d 6i | d 6d 6ƒ } t j j | d	 ƒ | _ t	 j
 d
 d d | ƒ | j d <d g | _ i d g d 6| _ i | d 6| _ t | ƒ } d | _ | j ƒ  |  j | j | j ƒ | j ƒ  |  j t | j ƒ  ƒ d ƒ t j j | d ƒ } t j | ƒ } |  j d | ƒ |  j d | ƒ t j r×|  j d | ƒ n |  j d | ƒ d  S(   Ns   __init__.pyt   ws   # Pretend this is a package.s
   README.txts   Info about this packaget   pkgt   packagest   package_dirs   setup.pyt   forcei    t	   build_libt   buildi   i   s   __init__.pyc(   t   mkdtempt   opent   ost   patht   joint   writet   closeR   t   script_nameR   t   DummyCommandt   command_objR   t   package_dataR	   R    t   compilet   ensure_finalizedt   assertEqualt   runt   lent   get_outputst   listdirt   assertInt   syst   dont_write_bytecodet   assertNotIn(   t   selft   sourcest   ft   destinationt   distt   cmdt   pkgdestt   files(    (    s.   lib/python2.7/distutils/tests/test_build_py.pyt   test_package_data   s@    		

	c         C   sW  t  j ƒ  } |  j ƒ  } t t  j j | d ƒ d ƒ j ƒ  t  j j | d ƒ } t  j | ƒ t t  j j | d ƒ d ƒ j ƒ  t  j | ƒ t	 j
 } t j ƒ  t	 _
 z– t i d g d 6i d d 6d 6i d	 g d 6d
 6ƒ } t  j j | d ƒ | _ d g | _ | j ƒ  y | j ƒ  Wn t k
 r7|  j d ƒ n XWd  t  j | ƒ | t	 _
 Xd  S(   Ns   __init__.pyR   t   doct   testfileR   R   t    R	   s   doc/*R   s   setup.pyR   s/   failed package_data test when package_dir is ''(   R   t   getcwdR   R   R   R   R   t   mkdirt   chdirR    t   stdoutt   StringIOR   R   t   script_argst   parse_command_linet   run_commandsR   t   fail(   R#   t   cwdR$   t   testdirt
   old_stdoutR'   (    (    s.   lib/python2.7/distutils/tests/test_build_py.pyt   test_empty_package_dirD   s,    ""	
c         C   sE  |  j  ƒ  } t j j | d ƒ } t j | ƒ t t j j | d ƒ d ƒ j ƒ  t j j | d ƒ } t j | ƒ t t j j | d ƒ d ƒ j ƒ  t j t j j | d ƒ ƒ t j | ƒ t i d g d 6i d g d 6d	 6ƒ } t j j | d
 ƒ | _	 d g | _
 | j ƒ  y | j ƒ  Wn t k
 r@|  j d ƒ n Xd S(   sR   
        A directory in package_data should not be added to the filelist.
        R   s   __init__.pyR   R,   R-   t   otherdirR   s   doc/*R   s   setup.pyR   s0   failed package_data when data dir includes a dirN(   R   R   R   R   R0   R   R   R1   R   R   R4   R5   R6   R   R7   (   R#   R$   t   pkg_dirt   docdirR'   (    (    s.   lib/python2.7/distutils/tests/test_build_py.pyt   test_dir_in_package_dataf   s$    ""
c         C   s   |  j  ƒ  \ } } t | ƒ } d | _ d | _ t j } t t _ z | j g  ƒ Wd  | t _ X|  j d |  j	 d d ƒ d  S(   Ni   s   byte-compiling is disabledi    (
   t   create_distR    R   t   optimizeR    R!   t   Truet   byte_compileR   t   logs(   R#   R=   R'   R(   t   old_dont_write_bytecode(    (    s.   lib/python2.7/distutils/tests/test_build_py.pyt   test_dont_write_bytecode…   s    				
(   t   __name__t
   __module__R+   R;   R?   RF   (    (    (    s.   lib/python2.7/distutils/tests/test_build_py.pyR      s   	0	"	c           C   s   t  j t ƒ S(   N(   t   unittestt	   makeSuiteR   (    (    (    s.   lib/python2.7/distutils/tests/test_build_py.pyt
   test_suite•   s    t   __main__(   t   __doc__R   R    R3   RI   t   distutils.command.build_pyR    t   distutils.coreR   t   distutils.errorsR   t   distutils.testsR   t   test.test_supportR   t   TempdirManagert   LoggingSilencert   TestCaseR   RK   RG   (    (    (    s.   lib/python2.7/distutils/tests/test_build_py.pyt   <module>   s   	ƒ	