
ryMc           @   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 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 d l m Z d d l m Z m Z d d l m Z m Z d d l m Z d d l m Z m  Z  d d l m! Z! d d l m" Z" d d l m# Z# m$ Z$ m% Z% d d l m& Z& m' Z' d d l m( Z( m) Z) d d l m* Z* m+ Z+ d d l m, Z, d d l m- Z- m. Z. d d l m/ Z/ m0 Z0 d d l m1 Z1 m2 Z2 d d l m3 Z3 e j4 d k r(d Z5 n e6 Z5 y d d l7 m8 Z8 Wn e9 k
 r[d Z: n Xe5 Z: y d d l; Z< Wn e9 e= f k
 rd Z> n1 Xe? e< d  d! f  d! d" f k  rd# Z> n e5 Z> e d$  oe d%  oe d&  re5 Z@ n d' Z@ e d(  o
e d)  re5 ZA n d* ZA d+   ZB d, eC f d-     YZD d. e eD f d/     YZE d0 e f d1     YZF d2 e f d3     YZG d4 e f d5     YZH d6 eC f d7     YZI d8 e eI f d9     YZJ d: e f d;     YZK d< e eI f d=     YZL d> e eI f d?     YZM d@ e f dA     YZN dB e eD f dC     YZO dD eI eD e f dE     YZP dF eP f dG     YZQ dH eP f dI     YZR dJ eI eD e f dK     YZS d S(L   s   
Tests for L{twisted.python.release} and L{twisted.python._release}.

All of these tests are skipped on platforms other than Linux, as the release is
only ever performed on Linux.
iN(   t   StringIO(   t   minidom(   t   date(   t   TestCase(   t   set(   t   which(   t   release(   t   FilePath(   t   Version(   t   _changeVersionInFilet   getNextVersion(   t   findTwistedProjectst   replaceInFile(   t   replaceProjectVersion(   t   updateTwistedVersionInformationt   Project(   t   generateVersionFileData(   t   changeAllProjectVersions(   t   VERSION_OFFSETt
   DocBuildert
   ManBuilder(   t   NoDocumentsFoundt   filePathDelta(   t   CommandFailedt   BookBuilder(   t   DistributionBuildert
   APIBuilder(   t   BuildAPIDocsScript(   t   buildAllTarballst
   runCommand(   t   UncleanWorkingDirectoryt   NotWorkingDirectory(   t   ChangeVersionsScriptt   BuildTarballsScript(   t   NewsBuildert   posixs*   Release toolchain only supported on POSIX.(   t   lores   Lore is not present.s   Pydoctor is not present.t   version_infoi    i   s   Pydoctor is too old.t   latext   dvipst   ps2pdf13s   LaTeX is not available.t   svnt   svnadmins   svn or svnadmin is not present.c          O   s   t  t |  |    S(   s   
    A convenience for generating _version.py data.

    @param args: Arguments to pass to L{Version}.
    @param kwargs: Keyword arguments to pass to L{Version}.
    (   R   R   (   t   argst   kwargs(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt
   genVersionT   s    t   StructureAssertingMixinc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   
    A mixin for L{TestCase} subclasses which provides some methods for asserting
    the structure and contents of directories and files on the filesystem.
    c         C   sx   xq | D]i } | j  |  } t | | t  rP | j   |  j | | |  q | j | | j d t j   q Wd S(   s#  
        Create a set of directories and files given a dict defining their
        structure.

        @param root: The directory in which to create the structure.  It must
            already exist.
        @type root: L{FilePath}

        @param dirDict: The dict defining the structure. Keys should be strings
            naming files, values should be strings describing file contents OR
            dicts describing subdirectories.  All files are written in binary
            mode.  Any string values are assumed to describe text files and
            will have their newlines replaced with the platform-native newline
            convention.  For example::

                {"foofile": "foocontents",
                 "bardir": {"barfile": "bar
contents"}}
        @type dirDict: C{dict}
        s   
N(	   t   childt
   isinstancet   dictt   createDirectoryt   createStructuret
   setContentt   replacet   ost   linesep(   t   selft   roott   dirDictt   xR/   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR3   d   s    
c         C   s   g  | j    D] } | j   ^ q } x | D] } | j |  } t | | t  r |  j | j   d | j f  |  j | | |  n5 | j	   j
 t j d  } |  j | | | | j  | j |  q, W| r |  j d | j | f  n  d S(   s  
        Assert that a directory is equivalent to one described by a dict.

        @param root: The filesystem directory to compare.
        @type root: L{FilePath}
        @param dirDict: The dict that should describe the contents of the
            directory. It should be the same structure as the C{dirDict}
            parameter to L{createStructure}.
        @type dirDict: C{dict}
        s   %s is not a dir!s   
s#   There were extra children in %s: %sN(   t   childrent   basenameR/   R0   R1   t
   assertTruet   isdirt   patht   assertStructuret
   getContentR5   R6   R7   t   assertEqualst   removet   fail(   R8   R9   R:   R;   R<   R/   t   a(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyRA      s    %	c         C   sy   t  j j | j d  } t |  j    } | j   x$ | D] } | j | d | j q; W|  j | j	   d |  d S(   s  
        Assert that a tarfile content is equivalent to one described by a dict.

        @param outputFile: The tar file built by L{DistributionBuilder}.
        @type outputFile: L{FilePath}.
        @param dirDict: The dict that should describe the contents of the
            directory. It should be the same structure as the C{dirDict}
            parameter to L{createStructure}.
        @type dirDict: C{dict}
        s   r:bz2R@   i    N(
   t   tarfilet   TarFilet   openR@   R   t   mktempR2   t   extractRA   R<   (   R8   t
   outputFileR:   t   tarFilet	   extractedt   info(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   assertExtractedStructure   s    
(   t   __name__t
   __module__t   __doc__R3   RA   RP   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR.   _   s   		t   ChangeVersionTestc           B   sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s5   
    Twisted has the ability to change versions.
    c         C   sl   t  |  j    } t j j |  \ } } | j |  } | j   | j |  } | j |  j |  | S(   s   
        Create a file with the given content relative to a temporary directory.

        @param relativePath: The basename of the file to create.
        @param content: The content that the file will have.
        @return: The filename.
        (	   R   RJ   R6   R@   t   splitt   preauthChildt   makedirsR/   R4   (   R8   t   relativePatht   contentt   baseDirectoryt	   directoryt   filenamet   file(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   makeFile   s    
c         C   s]   t  j   } | j t } t d | d d  } |  j t | d | t d | d d   d S(   s   
        When calculating the next version to release when a release is
        happening in the same year as the last release, the minor version
        number is incremented.
        t   twistedi	   i    t   nowi
   N(   R   t   todayt   yearR   R   RC   R
   (   R8   R`   t   majort   version(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_getNextVersion   s
    c         C   sa   t  j   } | j t } t d | d d d  } |  j t | d | t d | d d   d S(   s   
        When calculating the next version to release when a release is
        happening in a later year, the minor version number is reset to 0.
        R_   i   i	   i    R`   N(   R   Ra   Rb   R   R   RC   R
   (   R8   R`   Rc   Rd   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt"   test_getNextVersionAfterYearChange   s
    c         C   s   d } t  | d d d  } |  j d d | j    } t  | d d d  } t | | | j  |  j | j   d | j    d	 S(
   s   
        _changeVersionInFile replaces the old version information in a file
        with the given new version information.
        t   fooi   i   i    t   READMEs   Hello and welcome to %s.i   i   N(   R   R^   t   baseR	   R@   t   assertEqualRB   (   R8   t   packageNamet
   oldVersionR]   t
   newVersion(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_changeVersionInFile   s    	c         C   s"  t  |  j    } | j   i d d 6i i d d 6d 6t d d d d  d 6i i d d 6d 6t d	 d d d  d 6d
 6d 6} |  j | |  t | t d d d d   i d d 6i i d d 6d 6t d d d d  d 6i i d d 6d 6t d	 d d d  d 6d
 6d 6} |  j | |  d S(   s   
        L{changeAllProjectVersions} changes all version numbers in _version.py
        and README files for all projects as well as in the the top-level
        README file.
        s   Hi this is 1.0.0.Rh   s   Hi this is 1.0.0t   topfilesR_   i   i    s   _version.pys   twisted.webt   webt   loli   s   Hi this is 1.0.2.s   Hi this is 1.0.2N(   R   RJ   R2   R-   R3   R   R   RA   (   R8   R9   t	   structuret   outStructure(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_changeAllProjectVersions   s2    
!!c      	   C   sr  t  |  j    } | j   d } d } i d d 6| | d 6i i d d 6| d 6d 6t d d	 d
 d
  d 6i i d d 6| d 6d 6t d d	 d
 d
 d	  d 6d 6d 6} |  j | |  t | t d d	 d
 d  d  d } d } i d d 6| | d 6i i d d 6| d 6d 6t d d	 d
 d  d 6i i d d 6| d 6d 6t d d	 d
 d  d 6d 6d 6} |  j | |  d S(   s  
        L{changeAllProjectVersions} changes all version numbers in _version.py
        and README files for all projects as well as in the the top-level
        README file. If the old version was a pre-release, it will change the
        version in NEWS files as well.
        sA   Twisted Core 1.0.0 (2009-12-25)
===============================

sG   Twisted Web 1.0.0pre1 (2009-12-25)
==================================

s   Hi this is 1.0.0.Rh   t   NEWSs   Hi this is 1.0.0Ro   R_   i   i    s   _version.pys   Hi this is 1.0.0pre1s   twisted.webRp   Rq   i   s
   2010-01-01s?   Twisted Web 1.0.2 (2010-01-01)
==============================

s   Hi this is 1.0.2.s   Hi this is 1.0.2N(   R   RJ   R2   R-   R3   R   R   RA   (   R8   R9   t   coreNewst   webNewsRr   Rs   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt'   test_changeAllProjectVersionsPreRelease  sF    
$!(	   RQ   RR   RS   R^   Re   Rf   Rn   Rt   Rx   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyRT      s   					%t   ProjectTestc           B   sY   e  Z d  Z d   Z d	 d  Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(
   s=   
    There is a first-class representation of a project.
    c         C   s   |  j  t |  t |   t | d t j d  } t | d t j d  } x3 t | |  D]" \ } } |  j  | j | j  qb Wd S(   sA   
        Assert that two lists of L{Project}s are equal.
        t   keyR[   N(   Rj   t   lent   sortedt   operatort
   attrgettert   zipR[   (   R8   t   observedProjectst   expectedProjectst   observedt   expected(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   assertProjectsEqualU  s    		c         C   s   | d k r+ t |  j    } | j   n  | j j d  } | } xL | D]D } | j |  } | j   sx | j   n  | j d  j d  qJ W| j d  j   | j d  j d  j | j	    t
 | j d  j |  t |  S(   s(  
        Make a Twisted-style project in the given base directory.

        @param baseDirectory: The directory to create files in
            (as a L{FilePath).
        @param version: The version information for the project.
        @return: L{Project} pointing to the created project.
        t   .s   __init__.pyt    Ro   Rh   s   _version.pyN(   t   NoneR   RJ   R2   t   packageRU   R/   t   existsR4   Ri   R   R@   R   (   R8   Rd   RZ   t   segmentsR[   t   segment(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   makeProjectb  s    	%c         G   sA   t  |  j    } | j   x | D] } |  j | |  q# W| S(   s   
        Create a series of projects underneath a temporary base directory.

        @return: A L{FilePath} for the base directory.
        (   R   RJ   R2   R   (   R8   t   versionsRZ   Rd   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   makeProjects|  s
    
c         C   s>   t  d d d d  } |  j |  } |  j | j   |  d S(   s5   
        Project objects know their version.
        Rg   i   i   i    N(   R   R   RC   t
   getVersion(   R8   Rd   t   project(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_getVersion  s    c         C   s   |  j  t d d d d   } t d d d d  } | j |  |  j | j   |  |  j | j j d  j d  j   d	  d
 S(   sc   
        Project objects know how to update the version numbers in those
        projects.
        t   bari   i   i    i   i	   Ro   Rh   s   3.2.9N(   R   R   t   updateVersionRC   R   R[   R/   RB   (   R8   R   Rm   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_updateVersion  s    c         C   s3   t  t d   } |  j t |  d | j  d S(   sH   
        The representation of a Project is Project(directory).
        R   s   Project(%r)N(   R   R   Rj   t   reprR[   (   R8   Rg   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt	   test_repr  s    c         C   s}   |  j  t d d d d  t d d d d   } t |  } |  j | t | j d   t | j d  j d   g  d	 S(
   s   
        findTwistedStyleProjects finds all projects underneath a particular
        directory. A 'project' is defined by the existence of a 'topfiles'
        directory and is returned as a Project object.
        Rg   i   i   i    s   foo.bari   i   R   N(   R   R   R   R   R   R/   (   R8   RZ   t   projects(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_findTwistedStyleProjects  s    *c         C   s   t  |  j    } | j   t j   } d } t | d d d  } t | d | } |  j | |  } t | d | |  j	 | j
   |  |  j	 | j j d  j d  j   | j    d S(	   sq   
        Update Twisted version information in the top-level project and all of
        the subprojects.
        Rg   i   i   i    R`   Ro   Rh   N(   R   RJ   R2   R   Ra   R   R
   R   R   Rj   R   R[   R/   RB   Ri   (   R8   RZ   R`   t   projectNameRl   Rm   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt$   test_updateTwistedVersionInformation  s    
N(   RQ   RR   RS   R   R   R   R   R   R   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyRy   P  s   								t   UtilityTestc           B   s    e  Z d  Z d   Z d   Z RS(   s<   
    Tests for various utility functions for releasing.
    c         C   sE   t  j   } d   } |  j t t j |  |  j | t  j    d S(   s   
        Test that the runChdirSafe is actually safe, i.e., it still
        changes back to the original directory even if an error is
        raised.
        c           S   s&   t  j d  t  j d  d d d  S(   Nt	   releaseChi   i    (   R6   t   mkdirt   chdir(    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt
   chAndBreak  s    N(   R6   t   getcwdt   assertRaisest   ZeroDivisionErrorR   t   runChdirSafeRC   (   R8   t   cwdR   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt
   test_chdir  s
    		c         C   s   d } t  d d  } | j |  | j   | j d d  } t d i d d 6 |  j t  d  j   |  | j d d  } t d i d d 6 |  j t  d  j   |  d S(   s   
        L{replaceInFile} replaces data in a file based on a dict. A key from
        the dict that is found in the file is replaced with the corresponding
        value.
        s   foo
hey hey $VER
bar
s   release.replacet   ws   $VERs   2.0.0s   3.0.0N(   RI   t   writet   closeR5   R   RC   t   read(   R8   t   in_t   outfR   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_replaceInFile  s    
(   RQ   RR   RS   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s   	t   VersionWritingTestc           B   s    e  Z d  Z d   Z d   Z RS(   s-   
    Tests for L{replaceProjectVersion}.
    c         C   sT   t  d t d d d d   i d d 6} t d |  |  j | d j   d  d	 S(
   s   
        L{replaceProjectVersion} writes a Python file that defines a
        C{version} variable that corresponds to the given name and version
        number.
        t   test_projects   twisted.test_projecti    iR   i   t	   __name___Rd   s   0.82.7N(   R   R   t   execfileRC   Ri   (   R8   t   ns(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_replaceProjectVersion  s
    c      	   C   sZ   t  d t d d d d d d  i d d 6} t d |  |  j | d	 j   d
  d S(   s   
        L{replaceProjectVersion} will write a Version instantiation that
        includes a prerelease parameter if necessary.
        R   s   twisted.test_projecti    iR   i   t
   prereleasei   R   Rd   s
   0.82.7pre8N(   R   R   R   RC   Ri   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt(   test_replaceProjectVersionWithPrerelease  s    
(   RQ   RR   RS   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s   	t   BuilderTestsMixinc           B   sk   e  Z d  Z d Z d   Z d   Z d d d  Z d   Z d d d  Z d	   Z	 d
   Z
 d d  Z RS(   sx  
    A mixin class which provides various methods for creating sample Lore input
    and output.

    @cvar template: The lore template that will be used to prepare sample
    output.
    @type template: C{str}

    @ivar docCounter: A counter which is incremented every time input is
        generated and which is included in the documents.
    @type docCounter: C{int}
    s   
    <html>
    <head><title>Yo:</title></head>
    <body>
    <div class="body" />
    <a href="index.html">Index</a>
    <span class="version">Version: </span>
    </body>
    </html>
    c         C   s   d |  _  d S(   sP   
        Initialize the doc counter which ensures documents are unique.
        i    N(   t
   docCounter(   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   setUp4  s    c         C   s2   |  j  t j |  j   t j |  j    d S(   sJ   
        Verify that two strings represent the same XML document.
        N(   Rj   t   domt   parseStringt   toxml(   R8   t   firstt   second(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   assertXMLEqual;  s    R   s   %sc         C   s@   d } t  j | i | d 6| d 6| d 6| d d 6 j d  S(	   sJ  
        Get the correct HTML output for the arbitrary input returned by
        L{getArbitraryLoreInput} for the given parameters.

        @param version: The version string to include in the output.
        @type version: C{str}
        @param counter: A counter to include in the output.
        @type counter: C{int}
        sO  <?xml version="1.0"?><html>
    <head><title>Yo:Hi! Title: %(count)d</title></head>
    <body>
    <div class="content">Hi! %(count)d<div class="API"><a href="%(foobarLink)s" title="foobar">foobar</a></div></div>
    <a href="%(prefix)sindex.html">Index</a>
    <span class="version">Version: %(version)s</span>
    </body>
    </html>t   countt   prefixRd   t   foobart
   foobarLinks   utf-8(   R   (   R   R   R   (   R8   Rd   t   counterR   t
   apiBaseURLt   document(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   getArbitraryOutputD  s
    c         C   s   d } | i | d 6S(   s   
        Get an arbitrary, unique (for this test case) string of lore input.

        @param counter: A counter to include in the input.
        @type counter: C{int}
        st   <html><head><title>Hi! Title: %(count)s</title></head><body>Hi! %(count)s<div class="API">foobar</div></body></html>R   (    (   R8   R   t   template(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   getArbitraryLoreInput^  s    c         C   s@   |  j  d 7_  |  j |  j   |  j | |  j  d | d | f S(   s  
        Get an input document along with expected output for lore run on that
        output document, assuming an appropriately-specified C{self.template}.

        @param version: A version string to include in the input and output.
        @type version: C{str}
        @param prefix: The prefix to include in the link to the index.
        @type prefix: C{str}

        @return: A two-tuple of input and expected output.
        @rtype: C{(str, str)}.
        i   R   R   (   R   R   R   (   R8   Rd   R   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   getArbitraryLoreInputAndOutputp  s    c         C   s   d S(   s4   
        Get an arbitrary man page content.
        s+  .TH MANHOLE "1" "August 2001" "" ""
.SH NAME
manhole \- Connect to a Twisted Manhole service
.SH SYNOPSIS
.B manhole
.SH DESCRIPTION
manhole is a GTK interface to Twisted Manhole services. You can execute python
code as if at an interactive Python console inside a running Twisted process
with this.(    (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   getArbitraryManInput  s    c         C   s   d S(   s   
        Get an arbitrary lore input document which represents man-to-lore
        output based on the man page returned from L{getArbitraryManInput}
        s.  <?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<title>MANHOLE.1</title></head>
<body>

<h1>MANHOLE.1</h1>

<h2>NAME</h2>

<p>manhole - Connect to a Twisted Manhole service
</p>

<h2>SYNOPSIS</h2>

<p><strong>manhole</strong> </p>

<h2>DESCRIPTION</h2>

<p>manhole is a GTK interface to Twisted Manhole services. You can execute python
code as if at an interactive Python console inside a running Twisted process
with this.</p>

</body>
</html>
(    (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   getArbitraryManLoreOutput  s     c         C   s(   t  j d i | d 6| d 6 j d  S(   s}  
        Get an arbitrary lore output document which represents the lore HTML
        output based on the input document returned from
        L{getArbitraryManLoreOutput}.

        @param version: A version string to include in the document.
        @type version: C{str}
        @param prefix: The prefix to include in the link to the index.
        @type prefix: C{str}
        sn  <?xml version="1.0" ?><html>
    <head><title>Yo:MANHOLE.1</title></head>
    <body>
    <div class="content">

<span/>

<h2>NAME<a name="auto0"/></h2>

<p>manhole - Connect to a Twisted Manhole service
</p>

<h2>SYNOPSIS<a name="auto1"/></h2>

<p><strong>manhole</strong> </p>

<h2>DESCRIPTION<a name="auto2"/></h2>

<p>manhole is a GTK interface to Twisted Manhole services. You can execute python
code as if at an interactive Python console inside a running Twisted process
with this.</p>

</div>
    <a href="%(prefix)sindex.html">Index</a>
    <span class="version">Version: %(version)s</span>
    </body>
    </html>R   Rd   s   utf-8(   R   R   R   (   R8   Rd   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   getArbitraryManHTMLOutput  s    (   RQ   RR   RS   R   R   R   R   R   R   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s   
						"t   DocBuilderTestCasec           B   s   e  Z d  Z e Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z RS(   se  
    Tests for L{DocBuilder}.

    Note for future maintainers: The exact byte equality assertions throughout
    this suite may need to be updated due to minor differences in lore. They
    should not be taken to mean that Lore must maintain the same byte format
    forever. Feel free to update the tests when Lore changes, but please be
    careful.
    c         C   sg   t  j |   t   |  _ t |  j    |  _ |  j j   |  j j d  |  _	 |  j	 j
 |  j  d S(   s  
        Set up a few instance variables that will be useful.

        @ivar builder: A plain L{DocBuilder}.
        @ivar docCounter: An integer to be used as a counter by the
            C{getArbitrary...} methods.
        @ivar howtoDir: A L{FilePath} representing a directory to be used for
            containing Lore documents.
        @ivar templateFile: A L{FilePath} representing a file with
            C{self.template} as its content.
        s   template.tplN(   R   R   R   t   builderR   RJ   t   howtoDirR2   R/   t   templateFileR4   R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s    c         C   s   d } |  j  |  \ } } |  j  |  \ } } |  j j d  j |  |  j j d  j |  |  j j | |  j |  j |  j  |  j j d  } |  j j d  } |  j | j   |  |  j | j   |  d S(   sU   
        The L{DocBuilder} runs lore on all .xhtml files within a directory.
        s   1.2.3s	   one.xhtmls	   two.xhtmls   one.htmls   two.htmlN(	   R   R   R/   R4   R   t   buildR   R   RB   (   R8   Rd   t   input1t   output1t   input2t   output2t   out1t   out2(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt
   test_build  s    
c         C   s/   |  j  t |  j j d |  j |  j |  j  d S(   s}   
        The C{build} method raises L{NoDocumentsFound} if there are no
        .xhtml files in the given directory.
        s   1.2.3N(   R   R   R   R   R   R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_noDocumentsFound  s    c         C   s   |  j  d  } |  j j d  } | j   | j d  j |  |  j j d |  j | |  j  | j d  } |  j d | j	    d S(   s   
        The L{DocBuilder} generates correct links from documents to
        template-generated links like stylesheets and index backreferences.
        i    t   tutorials   child.xhtmls   1.2.3s
   child.htmls!   <a href="../index.html">Index</a>N(
   R   R   R/   R2   R4   R   R   R   t   assertInRB   (   R8   t   inputt   tutoDirt   outFile(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_parentDocumentLinking  s    
	c         C   s   |  j  d  } |  j j d  } |  j j d  } | j   | j d  j |  |  j j d | | |  j  | j d  } |  j d | j	    d S(	   s   
        It is necessary to generate documentation in a directory foo/bar where
        stylesheet and indexes are located in foo/baz. Such resources should be
        appropriately linked to.
        i    t	   resourcest   docss   child.xhtmls   1.2.3s
   child.htmls+   <a href="../resources/index.html">Index</a>N(
   R   R   R/   R2   R4   R   R   R   R   RB   (   R8   R   t   resourceDirt   docDirR   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt$   test_siblingDirectoryDocumentLinking.  s    
	c         C   s   d } |  j  |  \ } } |  j j d  j |  |  j j | |  j |  j |  j d  |  j j d  } |  j d | j    d S(   sh   
        The L{DocBuilder} generates correct links from documents to API
        documentation.
        s   1.2.3s	   one.xhtmls   scheme:apilinks/%s.exts   one.htmls>   <a href="scheme:apilinks/foobar.ext" title="foobar">foobar</a>N(	   R   R   R/   R4   R   R   R   R   RB   (   R8   Rd   R   t   outputt   out(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_apiLinking?  s    c         C   s   |  j  d  } |  j j d  j |  |  j j d |  j |  j |  j d t |  j |  j j d  j	    |  j
 |  j j d  j	    d S(   s   
        L{DocBuilder.build} can be instructed to delete the input files after
        generating the output based on them.
        i    s	   one.xhtmlt   whatevert   deleteInputs   one.htmlN(   R   R   R/   R4   R   R   R   t   TrueR>   R   t   assertFalse(   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_deleteInputP  s    c         C   s   |  j  d  } |  j j d  j |  |  j j d |  j |  j |  j  |  j |  j j d  j    |  j |  j j d  j    d S(   s7   
        Input will not be deleted by default.
        i    s	   one.xhtmlR   s   one.htmlN(	   R   R   R/   R4   R   R   R   R>   R   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_doNotDeleteInput]  s    
c         C   s5   |  j  j t d  t d   } |  j | d  d S(   sr   
        If the doc and resource directories are the same, the linkrel should be
        an empty string.
        s   /foo/barR   N(   R   t
   getLinkrelR   RC   (   R8   t   linkrel(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_getLinkrelToSameDirectoryi  s    c         C   s5   |  j  j t d  t d   } |  j | d  d S(   sy   
        If the doc directory is a child of the resource directory, the linkrel
        should make use of '..'.
        s   /foos   /foo/bars   ../N(   R   R   R   RC   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt    test_getLinkrelToParentDirectorys  s    c         C   s5   |  j  j t d  t d   } |  j | d  d S(   s   
        If the doc directory is a sibling of the resource directory, the
        linkrel should make use of '..' and a named segment.
        s
   /foo/howtos   /foo/exampless	   ../howto/N(   R   R   R   RC   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_getLinkrelToSibling}  s    c         C   s5   |  j  j t d  t d   } |  j | d  d S(   s   
        If the doc directory is a sibling of the parent of the resource
        directory, the linkrel should make use of multiple '..'s and a named
        segment.
        s
   /foo/howtos   /foo/examples/quotess   ../../howto/N(   R   R   R   RC   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_getLinkrelToUncle  s    (   RQ   RR   RS   t   loreSkipt   skipR   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s   										
	
	
t   APIBuilderTestCasec           B   s8   e  Z d  Z e Z d   Z d   Z d   Z d   Z RS(   s"   
    Tests for L{APIBuilder}.
    c         C   s  t    } |  j t d |  d } d } d } d } d } d } t |  j    j |  } | j   | j d  j d	 | | f  t |  j    }	 |	 j   t   }
 |
 j	 | | | | |	  |	 j d
  } |  j
 | j   d |	 j f  |  j d | | f | j   d  |	 j d  } |  j
 | j   d | j f  |  j | | j   d  |  j d | | f | j    |  j d | | f | j    |  j | | j    |  j
 | j d  j    |  j | j   d  d S(   st   
        L{APIBuilder.build} writes an index file which includes the name of the
        project specified.
        t   stdoutt   Foobart   quuxs   scheme:projects   scheme:sources   text in docstrings   should also appear in outputs   __init__.pys(   def foo():
    '%s'
def _bar():
    '%s's
   index.htmls   API index %r did not exist.s   <a href="%s">%s</a>s+   Project name/location not in file contents.s	   quux.htmls,   Package documentation file %r did not exist.s,   Docstring not in package documentation file.s   <a href="%s/%s">View Source</a>s:   <a href="%s/%s/__init__.py#L1" class="functionSourceLink">s   quux.foo.htmlR   N(   R    t   patcht   sysR   RJ   R/   RW   R4   R   R   R>   R   R@   R   RB   t   siblingRj   t   getvalue(   R8   R   R   Rk   t
   projectURLt	   sourceURLt	   docstringt   privateDocstringt	   inputPatht
   outputPathR   t	   indexPatht   quuxPath(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     sT    	

				
c   	      C   sz  t    } |  j t d |  d } t |  j    } | j d  } | j   | j d  j d | f  | j d  j t d d d d   t |  j    } t	   } | j
 | |  | j d	  } |  j | j   d
 | j f  |  j d | j   d  | j d  } |  j | j   d | j f  |  j | | j   d  |  j d | j    |  j | j   d  d S(   s   
        L{BuildAPIDocsScript.buildAPIDocs} builds the API docs with values
        appropriate for the Twisted project.
        R   s   text in docstringR_   s   __init__.pys   def foo():
    '%s'
s   _version.pyi   i    s
   index.htmls   API index %r did not exist.s/   <a href="http://twistedmatrix.com/">Twisted</a>s+   Project name/location not in file contents.s   twisted.htmls,   Package documentation file %r did not exist.s,   Docstring not in package documentation file.sc   <a href="http://twistedmatrix.com/trac/browser/tags/releases/twisted-1.0.0/twisted">View Source</a>R   N(   R    R   R   R   RJ   R/   RW   R4   R-   R   t   buildAPIDocsR>   R   R@   R   RB   Rj   R   (	   R8   R   R   t   projectRoott   packagePathR  t   scriptR  t   twistedPath(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildWithPolicy  sD    	
				c         C   s[   t    } |  j t | j g   |  j t | j d g  |  j t | j d d d g  d S(   s   
        SystemExit is raised when the incorrect number of command line
        arguments are passed to the API building script.
        Rg   R   t   bazN(   R   R   t
   SystemExitt   main(   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt-   test_apiBuilderScriptMainRequiresTwoArguments  s    	c            s]   t    } g      f d   | _ | j d d g  |  j   t d  t d  f g  d S(   sk   
        The API building script invokes the same code that
        L{test_buildWithPolicy} tests.
        c            s     j  |  | f  S(   N(   t   append(   RF   t   b(   t   calls(    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   <lambda>  s    t   hellot   thereN(   R   R  R  RC   R   (   R8   R  (    (   R  sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_apiBuilderScriptMain  s
    	(	   RQ   RR   RS   t   pydoctorSkipR   R   R
  R  R  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s   	<	1	t   ManBuilderTestCasec           B   s8   e  Z d  Z e Z d   Z d   Z d   Z d   Z RS(   s"   
    Tests for L{ManBuilder}.
    c         C   s?   t  j |   t   |  _ t |  j    |  _ |  j j   d S(   s   
        Set up a few instance variables that will be useful.

        @ivar builder: A plain L{ManBuilder}.
        @ivar manDir: A L{FilePath} representing a directory to be used for
            containing man pages.
        N(   R   R   R   R   R   RJ   t   manDirR2   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR   $  s    c         C   s    |  j  t |  j j |  j  d S(   sy   
        L{ManBuilder.build} raises L{NoDocumentsFound} if there are no
        .1 files in the given directory.
        N(   R   R   R   R   R  (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR   2  s    c         C   s   |  j    } |  j j d  j |  |  j j |  j  |  j j d  j   } |  j   } | j d t	 j
  } |  j | |  d S(   s   
        Check that L{ManBuilder.build} find the man page in the directory, and
        successfully produce a Lore content.
        s   test1.1s   test1-man.xhtmls   
N(   R   R  R/   R4   R   R   RB   R   R5   R6   R7   RC   (   R8   t
   manContentR   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR   :  s    c         C   s   |  j    } |  j j d  j |  |  j j |  j  |  j j d  } | j t j  t   } | j d |  j |  j |  |  j j d  j	   } |  j
 | d  d S(   sr   
        Check that the content output by C{build} is compatible as input of
        L{DocBuilder.build}.
        s   test1.1s   template.tpls   1.2.3s   test1-man.htmls^  <?xml version="1.0" ?><html>
    <head><title>Yo:MANHOLE.1</title></head>
    <body>
    <div class="content">

<span/>

<h2>NAME<a name="auto0"/></h2>

<p>manhole - Connect to a Twisted Manhole service
</p>

<h2>SYNOPSIS<a name="auto1"/></h2>

<p><strong>manhole</strong> </p>

<h2>DESCRIPTION<a name="auto2"/></h2>

<p>manhole is a GTK interface to Twisted Manhole services. You can execute python
code as if at an interactive Python console inside a running Twisted process
with this.</p>

</div>
    <a href="index.html">Index</a>
    <span class="version">Version: 1.2.3</span>
    </body>
    </html>N(   R   R  R/   R4   R   R   R   R   R   RB   R   (   R8   R  R   t
   docBuilderR   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_toHTMLI  s    	(	   RQ   RR   RS   R   R   R   R   R   R  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR    s   			t   BookBuilderTestsc           B   s   e  Z d  Z e p e Z d   Z d   Z d d d  Z	 d   Z
 d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s#   
    Tests for L{BookBuilder}.
    c         C   sJ   d |  _  t |  j    |  _ |  j j   t j t j t j  |  _ d S(   sG   
        Make a directory into which to place temporary files.
        i    N(	   R   R   RJ   R   RW   t   signalt   SIGCHLDt   SIG_DFLt
   oldHandler(   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s    	c         C   s   t  j  t  j |  j  d  S(   N(   R  R  R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   tearDown  s    R   c         C   s2   |  j  j d | f  j } d i | d 6| d 6S(   s   
        Create and return a C{str} containing the LaTeX document which is
        expected as the output for processing the result of the document
        returned by C{self.getArbitraryLoreInput(counter)}.
        s   %d.xhtmlsB   \section{Hi! Title: %(count)s\label{%(path)s}}
Hi! %(count)sfoobarR   R@   (   R   R/   R@   (   R8   Rd   R   R   R   R@   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s    c         C   s2   t    } |  j | j t j d d g  d  d S(   s   
        L{BookBuilder.run} executes the command it is passed and returns a
        string giving the stdout and stderr of the command if it completes
        successfully.
        s   -csg   import sys; sys.stdout.write("hi\n"); sys.stdout.flush(); sys.stderr.write("bye\n"); sys.stderr.flush()s   hi
bye
N(   R   RC   t   runR   t
   executable(   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_runSuccess  s    			c         C   sj   t    } |  j t | j t j d d g  } |  j | j d  |  j | j d  |  j | j
 d  d S(   s   
        L{BookBuilder.run} executes the command it is passed and raises
        L{CommandFailed} if it completes unsuccessfully.
        s   -cs   print "hi"; raise SystemExit(1)i   s   hi
N(   R   R   R   R"  R   R#  RC   t
   exitStatust
   exitSignalR   R   (   R8   R   t   exc(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_runFailed  s    		c         C   sj   t    } |  j t | j t j d d g  } |  j | j d  |  j | j d  |  j | j
 d  d S(   s   
        L{BookBuilder.run} executes the command it is passed and raises
        L{CommandFailed} if it exits due to a signal.
        s   -csN   import sys; print "hi"; sys.stdout.flush(); import os; os.kill(os.getpid(), 9)i	   s   hi
N(   R   R   R   R"  R   R#  RC   R&  R%  R   R   (   R8   R   R'  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_runSignaled  s    			c         C   s   d } |  j  |  \ } } |  j  |  \ } } |  j j d  j |  |  j j d  j |  t   } | j |  j  |  j |  j j d  j   |  |  j |  j j d  j   |  d S(   sx   
        L{BookBuilder.buildTeX} writes intermediate TeX files for all lore
        input files in a directory.
        s   3.2.1s   1.xhtmls   2.xhtmls   1.texs   2.texN(   R   R   R/   R4   R   t   buildTeXRj   RB   (   R8   Rd   R   R   R   R   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildTeX  s    	"c         C   s,   t    } |  j t | j |  j j    d S(   sr   
        L{BookBuilder.buildTeX} raises L{ValueError} if passed a directory
        which does not exist.
        N(   R   R   t
   ValueErrorR*  R   t   temporarySibling(   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt$   test_buildTeXRejectsInvalidDirectory  s    	c         C   s'   |  j  j d  j d  |  j   d S(   sd   
        L{BookBuilder.buildTeX} ignores files which which don't end with
        ".xhtml".
        s   not-input.datt   >N(   R   R/   R4   R+  (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildTeXOnlyBuildsXHTML  s    c         C   sV   t    } |  j t d |  |  j t d d    |  j   |  j | j   d  d S(   sC   
        L{BookBuilder.buildTeX} does not write to stdout.
        R   t   warnc          _   s   d  S(   N(   R   (   RF   t   kw(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR    s    R   N(   R    R   R   t   warningsR+  Rj   R   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_stdout  s
    	
c         C   s>   t    } |  j t | j t |  j    j d  d d  d S(   su   
        L{BookBuilder.buildPDF} raises L{ValueError} if the book filename does
        not end with ".tex".
        Rg   N(   R   R   R,  t   buildPDFR   RJ   R/   R   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt'   test_buildPDFRejectsInvalidBookFilename  s    	c         C   s&   t  d  } |  j |  |  j |  S(   Ni   (   t   ranget   _setupTeXSectionst   _setupTeXBook(   R8   t   sections(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   _setupTeXFiles  s    c         C   sG   x@ | D]8 } |  j  j d | f  } | j |  j d |   q Wd  S(   Ns   %d.texs   1.2.3(   R   R/   R4   R   (   R8   R:  t   texSectionNumbert   texPath(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR8    s    c         C   sN   |  j  j d  } | j d d j g  | D] } d | f ^ q(  d  | S(   Ns   book.texs&   \documentclass{book}
\begin{document}
s   
s   \input{%d.tex}s   \end{document}
(   R   R/   R4   t   join(   R8   R:  t   bookTeXt   n(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR9    s
    *c         C   sT   |  j    } t |  j    } t   } | j | |  j |  |  j | j    d S(   s~   
        L{BookBuilder.buildPDF} creates a PDF given an index tex file and a
        directory containing .tex files.
        N(   R;  R   RJ   R   R5  R   R>   R   (   R8   t   bookPathR  R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildPDF&  s
    	c         C   s   |  j  j d d  j d d  j d d  |  _  |  j  j   |  j   } t |  j    } t   } | j | |  j  |  |  j | j	    d S(   s  
        L{BookBuilder.buildPDF} succeeds even if the paths it is operating on
        are very long.

        C{ps2pdf13} seems to have problems when path names are long.  This test
        verifies that even if inputs have long paths, generation still
        succeeds.
        R;   i   N(
   R   R/   RW   R;  R   RJ   R   R5  R>   R   (   R8   RA  R  R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildPDFLongPath4  s    
3	c   
      C   s  d t  f d     Y} |  j   } t |  j    } |   } | j | |  j |  | j \ } } } } }	 |  j | |  |  j | |  |  j | d  d g d | f  |  j | d | j g d | | j f  |  j | d  d g d	 | f  |  j |	 d  d
 g d |	 f  d S(   sD   
        L{BookBuilder.buildPDF} runs C{latex} three times.
        t   InspectableBookBuilderc           B   s   e  Z d    Z d   Z RS(   c         S   s   t  j |   g  |  _ d  S(   N(   R   t   __init__t   commands(   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyRE  P  s    c         S   s    |  j  j |  t j |  |  S(   sI   
                Record the command and then execute it.
                (   RF  R  R   R"  (   R8   t   command(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR"  T  s    (   RQ   RR   RE  R"  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyRD  O  s   	i   R&   s%   LaTeX command %r does not seem right.is6   LaTeX command %r does not end with the book path (%r).R'   s%   dvips command %r does not seem right.R(   s(   ps2pdf13 command %r does not seem right.N(	   R   R;  R   RJ   R5  R   RF  RC   R@   (
   R8   RD  RA  R  R   t   latex1t   latex2t   latex3R'   R(   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt    test_buildPDFRunsLaTeXThreeTimesK  s*    	c         C   s   t  j   } |  j   } | j   j   } |  j j   } t   } | j | |  j t |  j	     |  j
 | t  j    |  j
 | | j   j    |  j
 | |  j j    d S(   s   
        The working directory is the same before and after a call to
        L{BookBuilder.buildPDF}.  Also the contents of the directory containing
        the input book are the same before and after the call.
        N(   R6   R   R;  t   parentR<   R   R   R5  R   RJ   Rj   (   R8   t   startDirR?  t   startTeXSiblingst   startHowtoChildrenR   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_noSideEffectsw  s    	"c         C   s   t  |  j   d  } t   } | j   j   } |  j t | j | |  j t  |  j     } |  j	 | j
  t | j   j    t |  } |  j t |  d  | j   } |  j	 | j   d | j f  d S(   s   
        If a subprocess fails, L{BookBuilder.buildPDF} raises L{CommandFailed}
        with the subprocess's output and leaves the temporary directory as a
        sibling of the book path.
        s   .texi   s*   Expected work path %r was not a directory.N(   R   RJ   R   RL  R<   R   R   R5  R   R>   R   R   Rj   R{   t   popR?   R@   (   R8   R?  R   t
   inputStateR'  t   newOutputStatet   workPath(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt    test_failedCommandProvidesOutput  s    	"	c         C   s   t  d d  } x7 | D]/ } |  j j d | f  j |  j |   q W|  j |  } t |  j    } t   } | j	 |  j |  j g | |  |  j
 | j    d S(   sd   
        L{BookBuilder.build} generates a pdf book file from some lore input
        files.
        i   i   s   %d.xhtmlN(   R7  R   R/   R4   R   R9  R   RJ   R   R   R>   R   (   R8   R:  t   sectionNumberR?  t   bookPDFR   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s    	c         C   s   t  d d  } x7 | D]/ } |  j j d | f  j |  j |   q W|  j |  } t |  j    } t   } | j	 |  j |  j g | |  |  j
 t |  j j    t | j   g g  | D] } d | f ^ q   d S(   sW   
        L{BookBuilder.build} removes the intermediate LaTeX files it creates.
        i   i   s   %d.xhtmlN(   R7  R   R/   R4   R   R9  R   RJ   R   R   Rj   R   t   listdirR=   (   R8   R:  RV  R?  RW  R   R@  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt$   test_buildRemovesTemporaryLaTeXFiles  s    	N(   RQ   RR   RS   t	   latexSkipR   R   R   R!  R   R   R$  R(  R)  R+  R.  R0  R4  R6  R;  R8  R9  RB  RC  RK  RP  RU  R   RY  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR  z  s.   	
						
	
					
			,			t   FilePathDeltaTestc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s%   
    Tests for L{filePathDelta}.
    c         C   s,   |  j  t t d  t d   d g  d S(   sU   
        L{filePathDelta} can create a simple relative path to a child path.
        s   /foo/bars   /foo/bar/bazR  N(   RC   R   R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_filePathDeltaSubdir  s    c         C   s/   |  j  t t d  t d   d d g  d S(   se   
        L{filePathDelta} can traverse upwards to create relative paths to
        siblings.
        s   /foo/bars   /foo/bazs   ..R  N(   RC   R   R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_filePathDeltaSiblingDir  s    c         C   s5   |  j  t t d  t d   d d d d g  d S(   sx   
        L{filePathDelta} can create relative paths to totally unrelated paths
        for maximum portability.
        s   /foo/bars	   /baz/quuxs   ..R  R   N(   RC   R   R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_filePathNoCommonElements  s    c         C   s5   |  j  t t d  t d   d d d d g  d S(   s   
        L{filePathDelta} doesn't take into account final elements when
        comparing 2 paths, but stops at the first difference.
        s   /foo/bar/bar/spams   /foo/bar/baz/spams   ..R  t   spamN(   RC   R   R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt$   test_filePathDeltaSimilarEndElements  s    (   RQ   RR   RS   R\  R]  R^  R`  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR[    s
   			
	
t   NewsBuilderTestsc           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s#   
    Tests for L{NewsBuilder}.
    c         C   s   t    |  _ t |  j    |  _ |  j j   d |  _ |  j |  j i |  j d 6d d 6d d 6d d 6d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6 d S(   sc   
        Create a fake project and stuff some basic structure and content into
        it.
        s,   Here is stuff which was present previously.
Ru   s   We now support the web.
s	   5.features   The widget is more robust.
s
   12.features   A very long feature which takes many words to describe with any accuracy was introduced so that the line wrapping behavior of the news generating code could be verified.
s
   15.features9   A simpler feature
described on multiple lines
was added.
s
   16.features   Broken stuff was fixed.
s	   23.bugfixs   Stupid stuff was deprecated.
s
   25.removalR   s   30.miscs   35.miscs   foo.bar.Baz.quuxs   40.docs   writing Foo serverss   41.docN(   R"   R   R   RJ   R   R2   t   existingTextR3   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s     	
c         C   s,   |  j  |  j j   t j   j d   d S(   sP   
        L{NewsBuilder._today} returns today's date in YYYY-MM-DD form.
        s   %Y-%m-%dN(   RC   R   t   _todayR   Ra   t   strftime(   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt
   test_today  s    c         C   s>   |  j  j |  j |  j  j  } |  j | d
 d d d g  d	 S(   s   
        When called with L{NewsBuilder._FEATURE}, L{NewsBuilder._findChanges}
        returns a list of bugfix ticket numbers and descriptions as a list of
        two-tuples.
        i   s   We now support the web.i   s   The widget is more robust.i   s   A very long feature which takes many words to describe with any accuracy was introduced so that the line wrapping behavior of the news generating code could be verified.i   s8   A simpler feature described on multiple lines was added.N(   i   s   We now support the web.(   i   s   The widget is more robust.(   i   s   A very long feature which takes many words to describe with any accuracy was introduced so that the line wrapping behavior of the news generating code could be verified.(   i   s8   A simpler feature described on multiple lines was added.(   R   t   _findChangesR   t   _FEATURERC   (   R8   t   features(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_findFeatures  s    	 c         C   s5   |  j  j |  j |  j  j  } |  j | d g  d S(   s   
        When called with L{NewsBuilder._BUGFIX}, L{NewsBuilder._findChanges}
        returns a list of bugfix ticket numbers and descriptions as a list of
        two-tuples.
        i   s   Broken stuff was fixed.N(   i   s   Broken stuff was fixed.(   R   Rf  R   t   _BUGFIXRC   (   R8   t   bugfixes(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_findBugfixes/  s
    	c         C   s5   |  j  j |  j |  j  j  } |  j | d g  d S(   s   
        When called with L{NewsBuilder._REMOVAL}, L{NewsBuilder._findChanges}
        returns a list of removal/deprecation ticket numbers and descriptions
        as a list of two-tuples.
        i   s   Stupid stuff was deprecated.N(   i   s   Stupid stuff was deprecated.(   R   Rf  R   t   _REMOVALRC   (   R8   t   removals(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_findRemovals<  s
    	c         C   s8   |  j  j |  j |  j  j  } |  j | d d g  d S(   s   
        When called with L{NewsBuilder._DOC}, L{NewsBuilder._findChanges}
        returns a list of documentation ticket numbers and descriptions as a
        list of two-tuples.
        i(   s   foo.bar.Baz.quuxi)   s   writing Foo serversN(   i(   s   foo.bar.Baz.quux(   i)   s   writing Foo servers(   R   Rf  R   t   _DOCRC   (   R8   t   doc(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_findDocumentationI  s    	c         C   s8   |  j  j |  j |  j  j  } |  j | d d g  d S(   s   
        When called with L{NewsBuilder._MISC}, L{NewsBuilder._findChanges}
        returns a list of removal/deprecation ticket numbers and descriptions
        as a list of two-tuples.
        i   R   i#   N(   i   R   (   i#   R   (   R   Rf  R   t   _MISCRC   (   R8   t   misc(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_findMiscellaneousW  s    	c         C   s6   t    } |  j j | d  |  j | j   d  d S(   s   
        L{NewsBuilder._writeHeader} accepts a file-like object opened for
        writing and a header string and writes out a news file header to it.
        s   Super Awesometastic 32.16s5   Super Awesometastic 32.16
=========================

N(   R    R   t   _writeHeaderRC   R   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_writeHeadere  s
    		c         C   s?   t    } |  j j | d d d	 g  |  j | j   d  d S(
   s  
        L{NewsBuilder._writeSection} accepts a file-like object opened for
        writing, a section name, and a list of ticket information (as returned
        by L{NewsBuilder._findChanges}) and writes out a section header and all
        of the given ticket information.
        t   Featuresi   s   Great stuff.i   sm   Very long line which goes on and on and on, seemingly without end until suddenly without warning it does end.s   Features
--------
 - Great stuff. (#3)
 - Very long line which goes on and on and on, seemingly without end
   until suddenly without warning it does end. (#17)

N(   i   s   Great stuff.(   i   sm   Very long line which goes on and on and on, seemingly without end until suddenly without warning it does end.(   R    R   t   _writeSectionRC   R   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_writeSections  s    		
	c         C   s^   t    } |  j j | d g  t d d d  D] } | d f ^ q+  |  j | j   d  d S(   s-  
        L{NewsBuilder._writeMisc} accepts a file-like object opened for
        writing, a section name, and a list of ticket information (as returned
        by L{NewsBuilder._findChanges} and writes out a section header and all
        of the ticket numbers, but excludes any descriptions.
        t   Otheri   i2   i   R   s_   Other
-----
 - #2, #5, #8, #11, #14, #17, #20, #23, #26, #29, #32, #35, #38, #41,
   #44, #47

N(   R    R   t
   _writeMiscR7  RC   R   (   R8   R   R;   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_writeMisc  s    		,	c         C   sX   |  j  j |  j |  j j d  d  |  j j d  j   } |  j | d |  j  d S(   s   
        L{NewsBuilder.build} updates a NEWS file with new features based on the
        I{<ticket>.feature} files found in the directory specified.
        Ru   s   Super Awesometastic 32.16s  Super Awesometastic 32.16
=========================

Features
--------
 - We now support the web. (#5)
 - The widget is more robust. (#12)
 - A very long feature which takes many words to describe with any
   accuracy was introduced so that the line wrapping behavior of the
   news generating code could be verified. (#15)
 - A simpler feature described on multiple lines was added. (#16)

Bugfixes
--------
 - Broken stuff was fixed. (#23)

Improved Documentation
----------------------
 - foo.bar.Baz.quux (#40)
 - writing Foo servers (#41)

Deprecations and Removals
-------------------------
 - Stupid stuff was deprecated. (#25)

Other
-----
 - #30, #35


N(   R   R   R   R/   RB   RC   Rb  (   R8   t   results(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s    	c         C   s   t  |  j    j d  } | j   |  j | i |  j d 6 |  j j | | j d  d  | j d  j   } |  j	 | d |  j j
 d |  j  d S(   s   
        If no changes exist for a project, I{NEWS} gains a new section for
        that project that includes some helpful text about how there were no
        interesting changes.
        R_   Ru   s   Super Awesometastic 32.16s5   Super Awesometastic 32.16
=========================

s   

N(   R   RJ   R/   RW   R3   Rb  R   R   RB   RC   t   _NO_CHANGES(   R8   R   R~  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_emptyProjectCalledOut  s    
	c         C   sR   |  j  j d  } | j d  |  j j |  j  | d  |  j | j   d  d S(   s   
        If a I{NEWS} file begins with the two magic lines which point readers
        at the issue tracker, those lines are kept at the top of the new file.
        Ru   s   Ticket numbers in this file can be looked up by visiting
http://twistedmatrix.com/trac/ticket/<number>

Blah blah other stuff.
s   Super Awesometastic 32.16s  Ticket numbers in this file can be looked up by visiting
http://twistedmatrix.com/trac/ticket/<number>

Super Awesometastic 32.16
=========================

Features
--------
 - We now support the web. (#5)
 - The widget is more robust. (#12)
 - A very long feature which takes many words to describe with any
   accuracy was introduced so that the line wrapping behavior of the
   news generating code could be verified. (#15)
 - A simpler feature described on multiple lines was added. (#16)

Bugfixes
--------
 - Broken stuff was fixed. (#23)

Improved Documentation
----------------------
 - foo.bar.Baz.quux (#40)
 - writing Foo servers (#41)

Deprecations and Removals
-------------------------
 - Stupid stuff was deprecated. (#25)

Other
-----
 - #30, #35


Blah blah other stuff.
N(   R   R/   R4   R   R   RC   RB   (   R8   t   news(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_preserveTicketHint  s    	c         C   s   x: |  j  j   D]) } | j   d d	 k r | j   q q W|  j j |  j  |  j  j d  d  |  j |  j  j d  j   d  d S(
   s   
        If there are no changes of a particular type (feature, bugfix, etc), no
        section for that type is written by L{NewsBuilder.build}.
        i   s   .features   .miscs   .docRu   s   Some Thing 1.2s   Some Thing 1.2
==============

Bugfixes
--------
 - Broken stuff was fixed. (#23)

Deprecations and Removals
-------------------------
 - Stupid stuff was deprecated. (#25)


Here is stuff which was present previously.
N(   s   .features   .miscs   .doc(	   R   R<   t   splitextRD   R   R   R/   RC   RB   (   R8   t   ticket(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_emptySectionsOmitted  s    	c            s     f d   } | d  j  | d   | d  j  | d     j j   j   j j d  d    j   j j d  j   d  d S(	   sr   
        If two change files have the same contents, they are merged in the
        generated news entry.
        c            s     j  j |  d  S(   Ns   .feature(   R   R/   (   t   s(   R8   (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   feature6  s    t   5t   15t   16Ru   s   Project Name 5.0s  Project Name 5.0
================

Features
--------
 - We now support the web. (#5, #15, #16)
 - The widget is more robust. (#12)

Bugfixes
--------
 - Broken stuff was fixed. (#23)

Improved Documentation
----------------------
 - foo.bar.Baz.quux (#40)
 - writing Foo servers (#41)

Deprecations and Removals
-------------------------
 - Stupid stuff was deprecated. (#25)

Other
-----
 - #30, #35


Here is stuff which was present previously.
N(   t   copyToR   R   R   R/   RC   RB   (   R8   R  (    (   R8   sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_duplicatesMerged1  s    	c      	   C   s   t  |  j    j d  } | j   |  j | i d d 6t d d d d  d 6i d d 6d	 d
 6d d 6d 6i t d d d d  d 6i d d 6d d 6d 6d 6 | S(   sF   
        Create a fake-looking Twisted project to build from.
        R_   s    Old boring stuff from the past.
Ru   i   i   i   s   _version.pys   Old core news.
s   Third feature addition.
s	   3.featureR   s   5.miscRo   s   twisted.conchi   i   s   Old conch news.
s   Fixed that bug.
s   7.bugfixt   conch(   R   RJ   R/   RW   R3   R-   (   R8   R   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   createFakeTwistedProject]  s    
c   
         s   g    t    }   f d   | _ d   | _ |  j   } | j |  | j d  } | j d  } d } | j d  j d  } | j d  } d } | j d  }	 |  j   | | | f | | | f | |	 | f | |	 | f g  d S(	   s  
        L{NewsBuilder.buildAll} calls L{NewsBuilder.build} once for each
        subproject, passing that subproject's I{topfiles} directory as C{path},
        the I{NEWS} file in that directory as C{output}, and the subproject's
        name as C{header}, and then again for each subproject with the
        top-level I{NEWS} file for C{output}. Blacklisted subprojects are
        skipped.
        c            s     j  |  | | f  S(   N(   R  (   R@   R   t   header(   t   builds(    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR  ~  s   c           S   s   d S(   Ns
   2009-12-01(    (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR    s    Ro   Ru   s   Twisted Core 1.2.3 (2009-12-01)R  s    Twisted Conch 3.4.5 (2009-12-01)N(   R"   R   Rc  R  t   buildAllR/   RC   (
   R8   R   R   t   coreTopfilesRv   t
   coreHeadert   conchTopfilest	   conchNewst   conchHeadert   aggregateNews(    (   R  sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildAlls  s&    		c         C   s   t    } d   | _ |  j   } | j |  t d d d d  } | j d  j d  } | j | d t d d	 d
 d  | d  d } |  j | d | j    d S(   s|   
        L{NewsBuilder._changeVersions} gets the release date for a given
        version of a project as a string.
        c           S   s   d S(   Ns
   2009-12-01(    (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR    s    t   TEMPLATEi   i   Ro   Ru   t   CoreR_   i   i   i   s
   2010-01-01s   Twisted Core 7.7.14 (2010-01-01)
================================

Features
--------
 - Third feature addition. (#3)

Other
-----
 - #5


s   Old core news.
N(	   R"   Rc  R  R  R   R/   t   _changeNewsVersionRC   RB   (   R8   R   R   Rm   Rv   t   expectedCore(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_changeVersionInNews  s    	

(   RQ   RR   RS   R   Re  Ri  Rl  Ro  Rr  Ru  Rw  Rz  R}  R   R  R  R  R  R  R  R  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyRa    s&   											+		3		,		$t   DistributionBuilderTestBasec           B   s   e  Z d  Z e Z d   Z RS(   s3   
    Base for tests of L{DistributionBuilder}.
    c         C   sm   t  j |   t |  j    |  _ |  j j   t |  j    |  _ |  j j   t |  j |  j  |  _ d  S(   N(	   R   R   R   RJ   t   rootDirR2   t	   outputDirR   R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s    (   RQ   RR   RS   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR    s   t   DistributionBuilderTestc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   sw  |  j  d  \ } } |  j   } |  j d d  } |  j   } |  j d d  } |  j  d d d \ } } i d d 6d d 6d	 d
 6d d 6i i d d 6d 6d d 6d 6i i d d 6i d d 6d d 6d 6d 6i d d 6d 6i d d 6d d 6d 6d 6i i i | d  6d! 6i | d" 6d# 6d 6i i |  j d$ 6d! 6i | d% 6d# 6| d  6d& 6d' 6}	 i d d 6d d 6d	 d
 6d d 6i i d d 6d 6d d 6d 6i i d d 6i d d 6d d 6d 6d 6i d d 6d 6i d d 6d d 6d 6d 6i i i | d( 6d! 6i | d" 6| d) 6d# 6d 6i i |  j d$ 6d! 6i | d% 6| d* 6d# 6| d( 6d& 6d' 6}
 |  j |  j |	  |  j j d  } |  j | |
  d+ S(,   ss   
        The Twisted tarball contains everything in the source checkout, with
        built documentation.
        s   10.0.0s	   ../howto/R   s   howto/t   TwistedRh   R;   t	   unrelateds
   copyright!t   LICENSEs   import toplevels   setup.pys   SET ROOTt
   websetrootRp   t   TWISTDt   twistdt   bins
   import WEBs   __init__.pys   import WEBINSTALLs   WEB!Ro   s   import WORDSt   wordss   import WEBPLUGs   twisted_web.pys   import WORDPLUGs   twisted_words.pyt   pluginsR_   s   index.xhtmlt   howtos   websetroot.1t   mans   template.tpls   twistd.1t   coreRq  s
   index.htmls   websetroot-man.htmls   twistd-man.htmlN(	   R   R   R   R   R3   R  R   t   buildTwistedRP   (   R8   t	   loreInputt
   loreOutputt	   manInput1t
   manOutput1t	   manInput2t
   manOutput2t   coreIndexInputt   coreIndexOutputRr   Rs   RL   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_twistedDistribution  sb    






c         C   s  i d d 6d d 6d d 6d d 6i i d	 d
 6d 6i d d 6d 6d 6i i d d 6i d d 6d d 6d 6d 6i d d 6d 6i d d 6d d 6d 6d 6} i d d 6d d 6d d 6i d	 d
 6d 6i i d d 6d 6i d d 6d 6d 6} |  j  |  j |  |  j j d d  } |  j | |  d S(   s  
        The subproject tarball includes files like so:

        1. twisted/<subproject>/topfiles defines the files that will be in the
           top level in the tarball, except LICENSE, which comes from the real
           top-level directory.
        2. twisted/<subproject> is included, but without the topfiles entry
           in that directory. No other twisted subpackages are included.
        3. twisted/plugins/twisted_<subproject>.py is included, but nothing
           else in plugins is.
        s   HI!@Rh   R;   R  s
   copyright!R  s   import toplevels   setup.pys   SET ROOTR  Rp   s   #!imt   imR  R  s
   import WEBs   __init__.pys   import WEBINSTALLs   WEB!Ro   s   import WORDSs   import WEBPLUGs   twisted_web.pys   import WORDPLUGs   twisted_words.pyR  R_   s   0.3.0N(   R3   R  R   t   buildSubProjectRP   (   R8   Rr   Rs   RL   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_subProjectLayout
  s0    


c         C   s   i d d 6i  d 6i i d d 6i d d 6d 6d	 6i  d
 6d 6} i d d 6d d 6i i d d 6d	 6d 6} |  j  |  j |  |  j j d	 d  } |  j | |  d S(   sG   
        buildSubProject should work with minimal subprojects.
        s
   copyright!R  R  s
   import WEBs   __init__.pys   import WEBINSTALLs   setup.pyRo   Rp   R  R_   s   0.3.0N(   R3   R  R   R  RP   (   R8   Rr   Rs   RL   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_minimalSubProjectLayout5  s    c         C   s4  |  j  d  \ } } |  j   } |  j d d  } i d d 6i i d d 6i d d 6d	 6d
 6d 6i i i | d 6d 6i | d 6d 6d
 6i i |  j d 6d 6d 6d 6} i d d 6d d 6i i d d 6d
 6d 6i i | d 6d 6i | d 6| d 6d 6d 6} |  j |  j |  |  j j d
 d  } |  j | |  d S(   sf   
        When building a subproject release, documentation should be built with
        lore.
        s   0.3.0s	   ../howto/s
   copyright!R  s
   import WEBs   __init__.pys   import WEBINSTs   setup.pyRo   Rp   R_   s   index.xhtmlR  s   twistd.1R  s   template.tplR  Rq  s
   index.htmls   twistd-man.htmlN(	   R   R   R   R   R3   R  R   R  RP   (   R8   R  R  t   manInputt	   manOutputRr   Rs   RL   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_subProjectDocBuildingM  s(    
c         C   s  |  j  d d d \ } } |  j  d  \ } } |  j  d d d \ } } |  j  d d d \ } } |  j  d d d \ }	 }
 i d d 6i d d	 6i d
 d	 6d d 6d
 6i d d	 6d d 6d 6d d 6i d d 6d d 6d d 6d 6i d d 6d d 6d 6d 6i i i |  j d 6| d 6i |	 d 6d 6d  6i | d 6d! 6i | d 6d" 6i d# d# 6d$ 6| d 6d% 6i i d& d 6d  6d' 6d( 6i d) d* 6i d+ d+ 6d' 6d, 6} i d d 6d d 6d d 6i d d	 6i d
 d	 6d d 6d
 6d d 6i d d 6d d 6d 6d 6i i |  j d 6| d- 6i |
 d- 6d 6d  6i | d- 6d! 6i | d- 6d" 6i d# d# 6d$ 6| d- 6d( 6i d) d* 6d, 6} |  j |  j |  |  j j d  } |  j | |  d. S(/   s   
        The core tarball looks a lot like a subproject tarball, except it
        doesn't include:

        - Python packages from other subprojects
        - plugins from other subprojects
        - scripts from other subprojects
        s   8.0.0R   s   howto/s	   ../howto/s   ../s
   copyright!R  R_   s   __init__.pyt   pythons   roots!s   roots.pyR  s   import conchs   unrelated.pyt   plugins	   plugin.pyt   webplugs   twisted_web.pys   include!s   twisted_whatever.pys   cred.pyR  s   import COREs   setup.pys   core readmeRh   Ro   s   template.tpls   index.xhtmlR   R  t   specificationst   upgradess   foo.pyt   examplesR  t   webindexRp   Rq  R  R  R  R  s
   index.htmlN(   R   R   R3   R  R   t	   buildCoreRP   (   R8   t
   indexInputt   indexOutputt
   howtoInputt   howtoOutputt	   specInputt
   specOutputt   upgradeInputt   upgradeOutputt   tutorialInputt   tutorialOutputRr   Rs   RL   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_coreProjectLayoutn  sj    	








c         C   s  d } t  |  j |  j d | } |  j d d | \ } } i d d 6i i d d 6i d d	 6d
 6d 6d 6i i i | d 6d 6d 6i i |  j d 6d 6d 6d 6} i d d 6d d	 6i i d d 6d 6d 6i i | d 6d 6d 6} |  j |  j |  | j d d  } |  j | |  d S(   sc   
        DistributionBuilder builds documentation with the specified
        API base URL.
        s	   http://%sR   s   0.3.0s
   copyright!R  s
   import WEBs   __init__.pys   import WEBINSTs   setup.pyRo   Rp   R_   s   index.xhtmlR  s   template.tplR  Rq  s
   index.htmlN(   R   R  R  R   R   R3   R  RP   (   R8   R   R   R  R  Rr   Rs   RL   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_apiBaseURL  s&    	(   RQ   RR   R  R  R  R  R  R  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR    s   	?	+		!	Ft   BuildAllTarballsTestc           B   sA   e  Z d  Z e Z d   Z d   Z d   Z d   Z d   Z	 RS(   s<   
    Tests for L{DistributionBuilder.buildAllTarballs}.
    c         C   s,   t  j  t  j t  j  |  _ t j |   d  S(   N(   R  R  R  R   R  R   (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR     s    c         C   s'   t  j  t  j |  j  t j |   d  S(   N(   R  R  R   R  R!  (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR!    s    c         C   sX  |  j    } t |  } |  j    } t |  } |  j j   t d d | g  t d d d | j | j g  |  j d d d d	 d
 \ } } i d d 6d d 6d d 6d d 6i i d d 6d 6d d 6d 6i i d d 6d d 6d 6t d d d d  d  6i d! d" 6t d# d d d  d  6i d$ d 6d% d 6d 6d 6i d& d' 6d( d) 6d* d+ 6d, 6d 6i i i |  j d- 6d. 6| d/ 6d0 6d1 6} i d d 6d d 6d d 6d d 6i d d 6i d d 6d 6d 6i i d d 6d d 6d 6t d d d d  d  6i d! d" 6t d# d d d  d  6i d$ d 6d% d 6d 6d 6i d& d' 6d( d) 6d* d+ 6d, 6d 6i i i |  j d- 6d. 6| d2 6d0 6d1 6} i d d 6d d 6d d 6i d d 6d 6i t d d d d  d  6i d* d+ 6d, 6d 6i i |  j d- 6d. 6| d2 6d1 6}	 i d% d 6d d 6d$ d 6i d d 6d 6i i d! d" 6t d# d d d  d  6d 6i d( d) 6d, 6d 6}
 |  j	 | |  g  | j
   D] } | j ^ qY} t d d3 g |  t d d4 | j d5 d6 g  t | |  j  |  j t |  j j
    t |  j j d7  |  j j d8  |  j j d9  g   |  j |  j j d7  |  |  j |  j j d8  |	  |  j |  j j d9  |
  d: S(;   s0  
        L{buildAllTarballs} builds tarballs for Twisted and all of its
        subprojects based on an SVN checkout; the resulting tarballs contain
        no SVN metadata.  This involves building documentation, which it will
        build with the correct API documentation reference base URL.
        R*   t   createR)   t   checkouts   file://s   1.2.0R   s   howto/R   s4   http://twistedmatrix.com/documents/1.2.0/api/%s.htmlR  Rh   R;   R  s
   copyright!R  s   import toplevels   setup.pys	   import imR  R  R  R  R  s   import TOPINSTALLs   CORE!Ro   R_   i   i   i    s   _version.pys   import WORDSs   __init__.pys   twisted.wordss   import WORDSINSTALLs   WORDS!s   import WEBPLUGs   twisted_web.pys   import WORDPLUGs   twisted_words.pys
   import YAYs   twisted_yay.pyR  s   template.tplR  s   index.xhtmlR  Rq  s
   index.htmlt   addt   commits   -mt   yays   Twisted-1.2.0.tar.bz2s   TwistedCore-1.2.0.tar.bz2s   TwistedWords-1.2.0.tar.bz2N(   RJ   R   R  RD   R   R@   R   R-   R   R3   R<   R   RC   R   R/   RP   (   R8   t   repositoryPatht
   repositoryt   checkoutPathR  R  R  Rr   t   twistedStructuret   coreStructuret   wordsStructureR;   t   childs(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildAllTarballs  s    









"c         C   s   |  j    } t |  } |  j    } t |  } t d d | g  t d d d | j | j g  | j d  j d  |  j t t | t |  j      d S(	   s   
        L{UncleanWorkingDirectory} is raised by L{buildAllTarballs} when the
        SVN checkout provided has uncommitted changes.
        R*   R  R)   R  s   file://Rg   R   N(	   RJ   R   R   R@   R/   R4   R   R   R   (   R8   R  R  R  R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt)   test_buildAllTarballsEnsuresCleanCheckoutV	  s    	c         C   sd   t  |  j    } |  j t t | t  |  j     | j   |  j t t | t  |  j     d S(   s   
        L{NotWorkingDirectory} is raised by L{buildAllTarballs} when the
        checkout passed does not exist or is not an SVN checkout.
        N(   R   RJ   R   R   R   R2   (   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt,   test_buildAllTarballsEnsuresExistingCheckouti	  s    	
	(
   RQ   RR   RS   t   svnSkipR   R   R!  R  R  R  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR    s   			s	t   ScriptTestsc           B   s}   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z RS(   s5   
    Tests for the release script functionality.
    c            s  g      f d   } t    } | | _ d | | | f } | d k	 rZ | d | f 7} n  | j | g  |  j t    d  |  j   d d t d   |  j   d d j |  |  j   d d j |  |  j   d d j	 |  |  j   d d j
 |  d S(   s   
        Check that L{ChangeVersionsScript.main} calls the version-changing
        function with the appropriate version data and filesystem path.
        c            s     j  |  | f  d  S(   N(   R  (   t
   sourceTreet   versionTemplate(   t   versionUpdates(    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   myVersionChanger	  s    s   %d.%d.%ds   pre%di   i    R   N(   R    R   R   R  RC   R{   R   Rc   t   minort   microR   (   R8   Rc   R  R  R   R  t   versionChangerRd   (    (   R  sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   _testVersionChanging~	  s    		c         C   s   |  j  d d d  d S(   sh   
        L{ChangeVersionsScript.main} changes version numbers for all Twisted
        projects.
        i   i   i   N(   R  (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_changeVersions	  s    c         C   s   |  j  d d d d  d S(   sK   
        A prerelease can be specified to L{changeVersionsScript}.
        i	   i   i   i&   N(   R  (   R8   (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt!   test_changeVersionsWithPrerelease	  s    c         C   s    t    } |  j | j t  d S(   ss   
        The default implementation of C{changeAllProjectVersions} is
        L{changeAllProjectVersions}.
        N(   R    RC   R   (   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt(   test_defaultChangeVersionsVersionChanger	  s    	c         C   s#   t    } |  j t | j g   d S(   sr   
        L{changeVersionsScript} raises SystemExit when the wrong number of
        arguments are passed.
        N(   R    R   R  R  (   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt/   test_badNumberOfArgumentsToChangeVersionsScript	  s    	c         C   s&   t    } |  j t | j d g  d S(   s   
        L{changeVersionsScript} raises SystemExit when there are the wrong
        number of segments in the version number passed.
        s   3.2.1.0N(   R    R   R  R  (   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt&   test_tooManyDotsToChangeVersionsScript	  s    	c         C   s&   t    } |  j t | j d g  d S(   sv   
        L{changeVersionsScript} raises SystemExit when the version number isn't
        made out of numbers.
        s   my united.states.of prewhateverN(   R    R   R  R  (   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt&   test_nonIntPartsToChangeVersionsScript	  s    	c            sc   g      f d   } t    } | | _ | j d d g  |  j   t d  t d  f g  d S(   s   
        L{BuildTarballsScript.main} invokes L{buildAllTarballs} with
        L{FilePath} instances representing the paths passed to it.
        c            s     j  |  | f  d  S(   N(   R  (   R  t   destination(   R  (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt	   myBuilder	  s    t   checkoutDirt   destinationDirN(   R!   R   R  RC   R   (   R8   R  t   tarballBuilder(    (   R  sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildTarballsScript	  s    		c         C   s    t    } |  j | j t  d S(   sw   
        The default implementation of L{BuildTarballsScript.buildAllTarballs}
        is L{buildAllTarballs}.
        N(   R!   RC   R   (   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt&   test_defaultBuildTarballsScriptBuilder	  s    	c         C   s#   t    } |  j t | j g   d S(   sv   
        L{BuildTarballsScript.main} raises SystemExit when the wrong number of
        arguments are passed.
        N(   R!   R   R  R  (   R8   R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt(   test_badNumberOfArgumentsToBuildTarballs	  s    	c         C   s?   t    } |  j t | j g   |  j t | j d d g  d S(   sn   
        L{NewsBuilder.main} raises L{SystemExit} when other than 1 argument is
        passed to it.
        R  t   worldN(   R"   R   R  R  (   R8   t   newsBuilder(    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt$   test_badNumberOfArgumentsToBuildNews	  s    	c         C   sH   g  } t    } | j | _ | j d g  |  j | t d  g  d S(   s   
        L{NewsBuilder.main} calls L{NewsBuilder.buildAll} with a L{FilePath}
        instance constructed from the path passed to it.
        s   /foo/bar/bazN(   R"   R  R  R  RC   R   (   R8   R  R  (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   test_buildNews	  s
    	N(   RQ   RR   RS   R   R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyR  y	  s   			
			
	
						
(T   RS   R3  R}   R6   R   R  R    RG   t   xml.domR   R   t   datetimeR   t   twisted.trial.unittestR   t   twisted.python.compatR   t   twisted.python.procutilsR   t   twisted.pythonR   t   twisted.python.filepathR   t   twisted.python.versionsR   t   twisted.python._releaseR	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R    R!   R"   t   nameR   R   t   twisted.lore.scriptsR$   t   ImportErrorR   t   pydoctor.drivert   pydoctort   SyntaxErrorR  t   getattrRZ  R  R-   t   objectR.   RT   Ry   R   R   R   R   R   R  R  R[  Ra  R  R  R  R  (    (    (    sD   /usr/lib/python2.7/dist-packages/twisted/python/test/test_release.pyt   <module>	   s   $	

!	$			P, \ M- 	 