ó
[³XMc           @   s®   d  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	 m
 Z
 d d l m Z d e f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s3   
Tests for parts of our release automation system.
iÿÿÿÿN(   t   Distribution(   t   TestCase(   t   dist(   t   get_setup_argst   ConditionalExtension(   t   FilePatht	   SetupTestc           B   s    e  Z d  Z d „  Z d „  Z RS(   s&   
    Tests for L{get_setup_args}.
    c         C   s¬   t  d d g d d „  ƒ} t  d d g d d „  ƒ} t d | | g ƒ } |  j | d | | g ƒ | d } | d	 } | t ƒ  ƒ } | j ƒ  |  j | j | g ƒ d
 S(   sÝ   
        Passing C{conditionalExtensions} as a list of L{ConditionalExtension}
        objects to get_setup_args inserts a custom build_ext into the result
        which knows how to check whether they should be 
        t   whatevers
   whatever.ct	   conditionc         S   s   t  S(   N(   t   True(   t   b(    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   <lambda>   s    c         S   s   t  S(   N(   t   False(   R
   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR   !   s    t   conditionalExtensionst   ext_modulest   cmdclasst	   build_extN(   R   R   t   assertEqualsR    t   prepare_extensionst
   extensions(   t   selft   good_extt   bad_extt   argsR   R   t   builder(    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_conditionalExtensions   s    


c         C   s~   t  d d g d d g ƒ} t d | g ƒ } | d d t ƒ  ƒ } |  j t d d	 ƒ | j ƒ  |  j | j d d g ƒ d S(   sT   
        When building on Windows NT, the WIN32 macro will be defined as 1.
        R   s
   whatever.ct   define_macrosi   R   R   R   t   namet   ntt   WIN32i   N(   s   whateveri   (   s   whateveri   (   R   i   (   R   R   R    t   patcht   osR   R   R   (   R   t   extR   R   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_win32Definition-   s    
(   t   __name__t
   __module__t   __doc__R   R!   (    (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR      s   	t   GetVersionTestc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s'   
    Tests for L{dist.getVersion}.
    c         C   s#   |  j  ƒ  |  _ t j |  j ƒ d  S(   N(   t   mktempt   dirnameR   t   mkdir(   R   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   setUp@   s    c         C   s^   t  t j j |  j d ƒ d ƒ } | j d ƒ | j ƒ  |  j t j	 d d |  j ƒd ƒ d S(   sg   
        Test that getting the version of core reads from the
        [base]/_version.py file.
        s   _version.pyt   wsT   
from twisted.python import versions
version = versions.Version("twisted", 0, 1, 2)
t   coret   bases   0.1.2N(
   t   openR   t   patht   joinR'   t   writet   closeR   R   t
   getVersion(   R   t   f(    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_getVersionCoreD   s
    !
c         C   s€   t  j t  j j |  j d ƒ ƒ t t  j j |  j d d ƒ d ƒ } | j d ƒ | j ƒ  |  j t	 j
 d d |  j ƒd ƒ d S(   s€   
        Test that getting the version of a non-core project reads from
        the [base]/[projname]/_version.py file.
        t   blats   _version.pyR*   sZ   
from twisted.python import versions
version = versions.Version("twisted.blat", 9, 8, 10)
R,   s   9.8.10N(   R   R(   R.   R/   R'   R-   R0   R1   R   R   R2   (   R   R3   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_getVersionOtherQ   s    $
(   R"   R#   R$   R)   R4   R6   (    (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR%   ;   s   		t   GetScriptsTestc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sÞ   |  j  ƒ  } t j | ƒ t j t j j | d ƒ ƒ t j t j j | d d ƒ ƒ t t j j | d d d ƒ d ƒ } | j d ƒ | j ƒ  t j	 d d | ƒ} |  j
 t | ƒ d ƒ |  j
 t j j | d ƒ d ƒ d	 S(
   sw   
        getScripts should return the scripts associated with a project
        in the context of Twisted SVN.
        t   bint   projt   exyR*   t   yayt   basediri   i    N(   R&   R   R(   R.   R/   R-   R0   R1   R   t
   getScriptsR   t   lent   basename(   R   R<   R3   t   scripts(    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_scriptsInSVNb   s    $
c         C   s¼   |  j  ƒ  } t j | ƒ t j t j j | d ƒ ƒ t t j j | d d ƒ d ƒ } | j d ƒ | j ƒ  t j	 d d | ƒ} |  j
 t | ƒ d ƒ |  j
 t j j | d ƒ d ƒ d	 S(
   s‰   
        getScripts should return the scripts associated with a project
        in the context of a released subproject tarball.
        R8   R:   R*   R;   R9   R<   i   i    N(   R&   R   R(   R.   R/   R-   R0   R1   R   R=   R   R>   R?   (   R   R<   R3   R@   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_scriptsInReleases   s    !
c         C   s}   |  j  ƒ  } t j | ƒ t j t j j | d ƒ ƒ t j t j j | d d ƒ ƒ t j d d | ƒ} |  j | g  ƒ d S(   sµ   
        When calling getScripts for a project which doesn't actually
        have any scripts, in the context of an SVN checkout, an
        empty list should be returned.
        R8   t	   otherprojt	   noscriptsR<   N(   R&   R   R(   R.   R/   R   R=   R   (   R   R<   R@   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_noScriptsInSVNƒ   s    c         C   s²   t  |  j ƒ  ƒ } | j ƒ  | j d ƒ } | j ƒ  | j d ƒ } | j d ƒ | j d ƒ } | j ƒ  | j d ƒ j d ƒ t j d d | j ƒ} |  j | | j g ƒ d	 S(
   s€   
        Passing the empty string to getScripts returns scripts that are (only)
        in the top level bin directory.
        R8   t   includeds   yay includedt   subdirs   not-includeds   not includedt    R<   N(	   R   R&   t   createDirectoryt   childt
   setContentR   R=   R.   R   (   R   R<   t   bindirRF   RG   R@   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_getScriptsTopLevel‘   s    


c         C   sB   |  j  ƒ  } t j | ƒ t j d d | ƒ} |  j | g  ƒ d S(   sÐ   
        When calling getScripts for a project which doesn't actually
        have any scripts in the context of that project's individual
        project structure, an empty list should be returned.
        RD   R<   N(   R&   R   R(   R   R=   R   (   R   R<   R@   (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   test_noScriptsInSubproject¤   s    (   R"   R#   RA   RB   RE   RM   RN   (    (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyR7   `   s
   				(   R$   R   t   distutils.coreR    t   twisted.trial.unittestR   t   twisted.pythonR   t   twisted.python.distR   R   t   twisted.python.filepathR   R   R%   R7   (    (    (    sA   /usr/lib/python2.7/dist-packages/twisted/python/test/test_dist.pyt   <module>   s   '%