ó
§xxTc           @   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 m Z d d l m	 Z	 d d l
 m Z m Z m Z y d d l Z Wn e k
 r§ e Z n Xy" d d l Z d d l Z e Z Wn e k
 rã e Z n Xd d l m Z m 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 d l# m$ Z$ d d l% m& Z& d Z' d Z( d e f d „  ƒ  YZ) d „  Z* e+ d k r±e e* ƒ  ƒ n  d S(   s"   Tests for distutils.command.sdist.iÿÿÿÿN(   t   join(   t   dedent(   t   captured_stdoutt   check_warningst   run_unittest(   t   sdistt   show_formats(   t   Distribution(   t   PyPIRCCommandTestCase(   t   DistutilsOptionError(   t   find_executable(   t   WARN(   t   FileList(   t   ARCHIVE_FORMATSsF   
from distutils.core import setup
import somecode

setup(name='fake')
sõ   # file GENERATED by distutils, do NOT edit
README
buildout.cfg
inroot.txt
setup.py
data%(sep)sdata.dt
scripts%(sep)sscript.py
some%(sep)sfile.txt
some%(sep)sother_file.txt
somecode%(sep)s__init__.py
somecode%(sep)sdoc.dat
somecode%(sep)sdoc.txt
t   SDistTestCasec           B   sÜ  e  Z d  „  Z d „  Z d d „ Z e j e d ƒ d „  ƒ Z	 e j e d ƒ d „  ƒ Z
 e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z d	 „  Z d
 „  Z d „  Z e j e d ƒ e j e d ƒ e j e d ƒ d k d ƒ e j e d ƒ d k d ƒ d „  ƒ ƒ ƒ ƒ Z d „  Z d „  Z d „  Z e j e j d k d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z e j e d ƒ d „  ƒ Z RS(   c         C   s¶   t  t |  ƒ j ƒ  t j ƒ  |  _ t j t |  j d ƒ ƒ t j t |  j d ƒ ƒ |  j	 |  j d f d ƒ |  j	 |  j d d f d ƒ |  j	 |  j d f t
 ƒ t j |  j ƒ d  S(   Nt   somecodet   distt   READMEt   xxxs   __init__.pyt   #s   setup.py(   t   superR   t   setUpt   ost   getcwdt   old_patht   mkdirR    t   tmp_dirt
   write_filet   SETUP_PYt   chdir(   t   self(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyR   ;   s    c         C   s'   t  j |  j ƒ t t |  ƒ j ƒ  d  S(   N(   R   R   R   R   R   t   tearDown(   R   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyR   I   s    c         C   s�   | d k r8 i d d 6d d 6d d 6d d 6d d 6} n  t | ƒ } d	 | _ d
 g | _ t | _ t | ƒ } d | _ | | f S(   s   Returns a cmdt   faket   names   1.0t   versionR   t   urlt   authort   author_emails   setup.pyR   R   N(   t   NoneR   t   script_namet   packagest   Truet   include_package_dataR   t   dist_dir(   R   t   metadataR   t   cmd(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   get_cmdN   s    			s   requires zlibc         C   sƒ  t  j t |  j d d ƒ ƒ |  j |  j d d d f d ƒ t  j t |  j d d ƒ ƒ |  j |  j d d d f d ƒ t  j t |  j d d ƒ ƒ |  j |  j d d d f d ƒ |  j |  j d d f d ƒ |  j ƒ  \ } } d	 g | _ | j ƒ  | j ƒ  t |  j d
 ƒ } t  j	 | ƒ } |  j
 | d g ƒ t j t | d ƒ ƒ } z | j ƒ  } Wd  | j ƒ  X|  j
 t | ƒ d ƒ d  S(   NR   s   .svns   ok.pyR   s   .hgt   oks   .gits   .nfs0001t   zipR   s   fake-1.0.zipi   (   R   R   R    R   R   R.   t   formatst   ensure_finalizedt   runt   listdirt   assertEqualt   zipfilet   ZipFilet   namelistt   closet   len(   R   R   R-   t   dist_foldert   filest   zip_filet   content(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_prune_file_list\   s*    

c         C   sø   |  j  ƒ  \ } } d d g | _ | j ƒ  | j ƒ  t |  j d ƒ } t j | ƒ } | j ƒ  |  j	 | d d g ƒ t j
 t | d ƒ ƒ t j
 t | d ƒ ƒ d d g | _ | j ƒ  | j ƒ  t j | ƒ } | j ƒ  |  j	 | d d g ƒ d  S(   Nt   gztart   tarR   s   fake-1.0.tars   fake-1.0.tar.gz(   R.   R1   R2   R3   R    R   R   R4   t   sortR5   t   remove(   R   R   R-   R;   t   result(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_make_distribution‡   s     





c         C   s‘   |  j  i d d 6d d 6ƒ \ } } d g | _ | j ƒ  | j ƒ  t |  j d ƒ } t j | ƒ } |  j | d g ƒ t j	 t | d ƒ ƒ d S(	   su   
        Unicode name or version should not break building to tar.gz format.
        Reference issue #11638.
        u   fakeR!   u   1.0R"   R@   R   s   fake-1.0.tar.gzN(
   R.   R1   R2   R3   R    R   R   R4   R5   RC   (   R   R   R-   R;   RD   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_unicode_metadata_tgz¤   s    #

c         C   sÀ  |  j  ƒ  \ } } i d d g d 6d g d 6| _ |  j |  j d d f d ƒ |  j |  j d d f d ƒ t |  j d	 ƒ } t j | ƒ |  j | d
 f d ƒ t |  j d ƒ } t j | ƒ t |  j d ƒ } t j | ƒ |  j | d f d ƒ |  j |  j d f d ƒ |  j |  j d f d ƒ |  j | d f d ƒ |  j | d f d ƒ d	 d d d d g f d d g | _ t |  j d ƒ } t j | ƒ |  j | d f d ƒ t d d ƒ g | _ d g | _	 t
 | _ | j ƒ  | j ƒ  t |  j d ƒ } t j | ƒ } |  j | d g ƒ t j t | d ƒ ƒ }	 z |	 j ƒ  }
 Wd  |	 j ƒ  X|  j t |
 ƒ d ƒ t t |  j d ƒ ƒ } z | j ƒ  } Wd  | j ƒ  X|  j | t i t j d 6ƒ d  S(   Ns   *.cfgs   *.datt    s   *.txtR   s   doc.txtR   s   doc.datt   datas   data.dtt   somes   .hgs   last-message.txts   buildout.cfgs
   inroot.txts   file.txts   other_file.txts   data/data.dtt   notexistings   some/file.txts   some/other_file.txtt   scriptss	   script.pyR0   R   s   fake-1.0.zipi   t   MANIFESTt   sep(   R.   t   package_dataR   R   R    R   R   t
   data_filesRK   R1   R)   t   use_defaultsR2   R3   R4   R5   R6   R7   R8   R9   R:   t   opent   readRL   RM   (   R   R   R-   t   data_dirt   some_dirt   hg_dirt
   script_dirR;   R<   R=   R>   t   ft   manifest(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_add_defaultsº   sX    		

c         C   s÷   |  j  d i  ƒ \ } } | j ƒ  | j ƒ  g  |  j t ƒ D] } | j d ƒ r< | ^ q< } |  j t | ƒ d ƒ |  j ƒ  |  j  ƒ  \ } } | j ƒ  d | _	 | j ƒ  g  |  j t ƒ D] } | j d ƒ r¼ | ^ q¼ } |  j t | ƒ d ƒ d  S(   NR,   s   warning: check:i   i    (
   R.   R2   R3   t   get_logsR   t
   startswithR5   R:   t
   clear_logst   metadata_check(   R   R   R-   t   msgt   warnings(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_metadata_check_option  s    



	
c         C   sX   |  j  ƒ  \ } } t ƒ  �7 } t j d ƒ | j ƒ  |  j t | j ƒ d ƒ Wd  QXd  S(   Nt   alwaysi   (   R.   R   R_   t   simplefiltert   check_metadataR5   R:   (   R   R   R-   t   w(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_check_metadata_deprecated  s
    
c         C   s‚   t  ƒ  � } t ƒ  Wd  QXt t j ƒ  ƒ } g  | j ƒ  j d ƒ D]! } | j ƒ  j d ƒ rA | ^ qA } |  j	 t | ƒ | ƒ d  S(   Ns   
s
   --formats=(
   R   R   R:   R   t   keyst   getvaluet   splitt   stripR[   R5   (   R   t   stdoutt   num_formatst   linet   output(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_show_formats"  s    !c         C   s§   |  j  ƒ  \ } } | j ƒ  |  j | j d ƒ |  j | j d ƒ |  j | j d ƒ d | _ |  j t | j ƒ d g | _ | j ƒ  d | _ |  j t | j ƒ d  S(   NRL   s   MANIFEST.inR   i   R0   t   supazipa(	   R.   t   finalize_optionsR5   RX   t   templateR+   R1   t   assertRaisesR	   (   R   R   R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_finalize_options,  s    
	
	s   Requires grp and pwd supportRA   s   The tar command is not foundt   gzips   The gzip command is not foundc         C   sm  |  j  ƒ  \ } } d g | _ t j d ƒ d | _ t j d ƒ d | _ | j ƒ  | j	 ƒ  t
 |  j d d ƒ } t j | ƒ } zA x: | j ƒ  D], } |  j | j d ƒ |  j | j d ƒ q’ WWd  | j ƒ  X|  j  ƒ  \ } } d g | _ | j ƒ  | j	 ƒ  t
 |  j d d ƒ } t j | ƒ } z4 x- | j ƒ  D] } |  j | j t j ƒ  ƒ q7WWd  | j ƒ  Xd  S(   NR@   i    R   s   fake-1.0.tar.gz(   R.   R1   t   pwdt   getpwuidt   ownert   grpt   getgrgidt   groupR2   R3   R    R   t   tarfileRQ   t
   getmembersR5   t   uidt   gidR9   R   t   getuid(   R   R   R-   t   archive_namet   archivet   member(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt"   test_make_distribution_owner_group@  s.    



!c         C   s{   |  j  ƒ  \ } } t j |  j ƒ |  j d | ƒ | j ƒ  t ƒ  | _ | j ƒ  |  j	 t
 ƒ } |  j t | ƒ d ƒ d  S(   Ns   MANIFEST.ini   (   R.   R   R   R   R   R2   R   t   filelistt   read_templateRZ   R   R5   R:   (   R   R>   R   R-   R_   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   _check_templates  s    

c         C   s   |  j  d ƒ d  S(   Ns   taunt knights *(   R†   (   R   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt%   test_invalid_template_unknown_command}  s    c         C   s   |  j  d ƒ d  S(   Nt   prune(   R†   (   R   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt%   test_invalid_template_wrong_arguments€  s    t   nts   test relevant for Windows onlyc         C   s   |  j  d ƒ d  S(   Ns   include examples/(   R†   (   R   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt    test_invalid_template_wrong_path„  s    c         C   s¯  |  j  ƒ  \ } } i d g d 6| _ |  j |  j d d f d ƒ d g | _ | j ƒ  | j ƒ  t | j ƒ } zD g  | j	 ƒ  j
 d ƒ D]$ } | j ƒ  d k r‰ | j ƒ  ^ q‰ } Wd  | j ƒ  X|  j t | ƒ d ƒ |  j |  j d d	 f d ƒ | j d
 ƒ } t | _ | j ƒ  | j ƒ  t | j ƒ } zD g  | j	 ƒ  j
 d ƒ D]$ } | j ƒ  d k rH| j ƒ  ^ qH} Wd  | j ƒ  X|  j t | ƒ d ƒ |  j d	 | d ƒ d  S(   Ns   *.txtR   s   doc.txtR   R@   s   
RG   i   s   doc2.txtt   build_pyi   iÿÿÿÿ(   R.   RN   R   R   R1   R2   R3   RQ   RX   RR   Rh   Ri   R9   R5   R:   t   get_command_objt   Falset	   finalizedt   assertIn(   R   R   R-   RW   Rl   RX   RŒ   t	   manifest2(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_get_file_listŠ  s0    

(	

(c         C   sŸ   |  j  ƒ  \ } } | j ƒ  | j ƒ  t | j ƒ } zD g  | j ƒ  j d ƒ D]$ } | j ƒ  d k rN | j ƒ  ^ qN } Wd  | j ƒ  X|  j	 | d d ƒ d  S(   Ns   
RG   i    s*   # file GENERATED by distutils, do NOT edit(
   R.   R2   R3   RQ   RX   RR   Rh   Ri   R9   R5   (   R   R   R-   RW   Rl   RX   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_manifest_marker´  s    

(c         C   s¶   t  d ƒ } |  j ƒ  \ } } | j ƒ  |  j |  j | j f | ƒ |  j |  j d f d ƒ |  j |  j d f d ƒ |  j |  j d f d ƒ | j ƒ  |  j | j j	 d g ƒ d  S(   NsI               # bad.py
            #bad.py
            good.py
            s   good.pys
   # pick me!s   bad.pys   # don't pick me!s   #bad.py(
   R   R.   R2   R   R   RX   R3   R5   R„   R<   (   R   t   contentsR   R-   (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_manifest_commentsÅ  s    	

c   
      C   si  |  j  ƒ  \ } } d g | _ | j ƒ  |  j |  j | j f d ƒ |  j |  j d f d ƒ | j ƒ  |  j | j j	 d g ƒ t
 | j ƒ } zD g  | j ƒ  j d ƒ D]$ } | j ƒ  d k r¨ | j ƒ  ^ q¨ } Wd  | j ƒ  X|  j | d g ƒ t |  j d d ƒ } t j
 | ƒ } z  g  | D] } | j ^ q"}	 Wd  | j ƒ  X|  j t |	 ƒ d d	 d
 g ƒ d  S(   NR@   s   README.manuals0   This project maintains its MANIFEST file itself.s   
RG   R   s   fake-1.0.tar.gzs   fake-1.0s   fake-1.0/PKG-INFOs   fake-1.0/README.manual(   R.   R1   R2   R   R   RX   R3   R5   R„   R<   RQ   RR   Rh   Ri   R9   R    R{   R!   t   sorted(
   R   R   R-   RW   Rl   RX   R€   R�   t   tarinfot	   filenames(    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   test_manual_manifestÖ  s*    

( N(   t   __name__t
   __module__R   R   R&   R.   t   unittestt
   skipUnlesst   zlibR?   RE   RF   RY   R`   Re   Rn   Rs   t   UID_GID_SUPPORTt   skipIfR
   Rƒ   R†   R‡   R‰   R   R!   R‹   R’   R“   R•   R™   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyR   9   s2   		+I		
	.	
		$*c           C   s   t  j t ƒ S(   N(   Rœ   t	   makeSuiteR   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt
   test_suiteô  s    t   __main__(,   t   __doc__R   R{   Rœ   R_   R6   t   os.pathR    t   textwrapR   t   test.test_supportR   R   R   Rž   t   ImportErrorR&   Rx   Ru   R)   RŸ   RŽ   t   distutils.command.sdistR   R   t   distutils.coreR   t   distutils.tests.test_configR   t   distutils.errorsR	   t   distutils.spawnR
   t   distutils.logR   t   distutils.filelistR   t   distutils.archive_utilR   R   RL   R   R¢   Rš   (    (    (    sF   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/distutils/tests/test_sdist.pyt   <module>   sB   


ÿ ¼	