
[XMc           @   s   d  d l  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 d Z d Z d	 Z d
 Z d e j f d     YZ d e j f d     YZ d S(   iN(   t   StringIO(   t   getVersionStringt   IncomparableVersions(   t   Versiont   _inf(   t   FilePath(   t   unittests  <?xml version="1.0" encoding="utf-8"?>
<wc-entries
   xmlns="svn:">
<entry
   committed-rev="18210"
   name=""
   committed-date="2006-09-21T04:43:09.542953Z"
   url="svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk/twisted"
   last-author="exarkun"
   kind="dir"
   uuid="bbbe8e31-12d6-0310-92fd-ac37d47ddeeb"
   repos="svn+ssh://svn.twistedmatrix.com/svn/Twisted"
   revision="18211"/>
</wc-entries>
s?   8

dir
22715
svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk
s?   9

dir
22715
svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk
s@   10

dir
22715
svn+ssh://svn.twistedmatrix.com/svn/Twisted/trunk
t   VersionsTestc           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 RS(   c         C   sV  t  d d d d  } t  d d d d  } |  j | | k  |  j | | k   |  j | | k  |  j | | k  |  j | | k  |  j | t  d d d d  k  |  j | | k  |  j | | k   |  j | | k  |  j | | k  |  j | | k  |  j | | k  |  j | t  d d d d  k  |  j | | k  d S(   sB   
        Versions can be compared for equality and order.
        t   dummyi   i    N(   R   t
   failUnlesst   failIf(   t   selft   vat   vb(    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_versionComparison?   s     ""c         C   sj   t  d d d d d d } t  d d d d  } |  j | | k   |  j | | k  |  j | |  d S(   sP   
        Prereleases are always less than versions without prereleases.
        t   whateveri   i    t
   prereleaseN(   R   t
   assertTruet   assertFalset   assertNotEquals(   R   R   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt%   test_comparingPrereleasesWithReleasesW   s
    c         C   sp   t  d d d d d d } t  d d d d d d } |  j | | k   |  j | | k  |  j | |  d S(   sW   
        The value specified as the prerelease is used in version comparisons.
        R   i   i    R   i   N(   R   R   R   t   assertNotEqual(   R   R   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_comparingPrereleasesb   s
    c         C   s   |  j  t t  d S(   sR   
        L{_inf} is equal to L{_inf}.

        This is a regression test.
        N(   t   assertEqualsR   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_infComparisonm   s    c      	   C   s8   |  j  t t t d d d d  t d d d d   d  S(   NR   i   i    t   dumym(   t   assertRaisesR   t   cmpR   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   testDontAllowBuggyComparisonsv   s    	c         C   s)   |  j  t t d d d d   d  d S(   su   
        Calling C{repr} on a version returns a human-readable string
        representation of the version.
        R   i   i   i   s   Version('dummy', 1, 2, 3)N(   R   t   reprR   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt	   test_repr}   s    c      	   C   s/   |  j  t t d d d d d d  d  d S(	   s   
        Calling C{repr} on a version with a prerelease returns a human-readable
        string representation of the version including the prerelease.
        R   i   i   i   R   i   s'   Version('dummy', 1, 2, 3, prerelease=4)N(   R   R   R   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_reprWithPrerelease   s    $c         C   s)   |  j  t t d d d d   d  d S(   st   
        Calling C{str} on a version returns a human-readable string
        representation of the version.
        R   i   i   i   s   [dummy, version 1.2.3]N(   R   t   strR   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_str   s    c      	   C   s/   |  j  t t d d d d d d  d  d S(   sX   
        Calling C{str} on a version with a prerelease includes the prerelease.
        R   i   i    R   s   [dummy, version 1.0.0pre1]N(   R   R    R   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_strWithPrerelease   s    $c         C   s)   |  j  t d d d d  j   d  d  S(   NR   i   i   i   s   1.2.3(   R   R   t   short(   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt	   testShort   s    c         C   s8   t  d d d d  } |  j | j t t   d  d S(   sO   
        Version should be able to parse an SVN format 4 entries file.
        R   i   i    t   18211N(   R   R   t   _parseSVNEntries_4R    t   VERSION_4_ENTRIES(   R   t   version(    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_goodSVNEntries_4   s    c         C   s8   t  d d d d  } |  j | j t t   d  d S(   sO   
        Version should be able to parse an SVN format 8 entries file.
        R   i   i    t   22715N(   R   t   assertEqualt   _parseSVNEntries_8R    t   VERSION_8_ENTRIES(   R   R(   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_goodSVNEntries_8   s    c         C   s8   t  d d d d  } |  j | j t t   d  d S(   sO   
        Version should be able to parse an SVN format 9 entries file.
        R   i   i    R*   N(   R   R+   t   _parseSVNEntries_9R    t   VERSION_9_ENTRIES(   R   R(   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_goodSVNEntries_9   s    c         C   s8   t  d d d d  } |  j | j t t   d  d S(   sP   
        Version should be able to parse an SVN format 10 entries file.
        R   i   i    R*   N(   R   R+   t   _parseSVNEntriesTenPlusR    t   VERSION_10_ENTRIES(   R   R(   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_goodSVNEntriesTenPlus   s    c         C   s)   |  j  d t t d d d d    d S(   sr   
        L{getVersionString} returns a string with the package name and the
        short version number.
        s   Twisted 8.0.0t   Twistedi   i    N(   R+   R   R   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_getVersionString   s    c      	   C   s/   |  j  t t d d d d d d  d  d S(   sF   
        L{getVersionString} includes the prerelease, if any.
        R   i   i    R   i   s   whatever 8.0.0pre1N(   R+   R   R   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt#   test_getVersionStringWithPrerelease   s    c         C   s)   |  j  t d d d d  j   d  d S(   sY   
        The L{base} method returns a very simple representation of the version.
        t   fooi   i    s   1.0.0N(   R   R   t   base(   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt	   test_base   s    c         C   s/   |  j  t d d d d d d j   d  d S(   sQ   
        The base version includes 'preX' for versions with prereleases.
        R8   i   i    R   i   s	   1.0.0pre8N(   R   R   R9   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_baseWithPrerelease   s    $(   t   __name__t
   __module__R   R   R   R   R   R   R   R!   R"   R$   R)   R.   R1   R4   R6   R7   R:   R;   (    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyR   =   s$   																											t   FormatDiscoveryTestsc           B   s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   sT   
    Tests which discover the parsing method based on the imported module name.
    c         C   s   t  |  j    |  _ t j j   |  _ t j j |  j j  |  j j	 d  } | j
   | j	 d  j d  | j	 d  |  _ |  j j
   d S(   sN   
        Create a temporary directory with a package structure in it.
        t   twisted_python_versions_packages   __init__.pysj   from twisted.python.versions import Version
version = Version('twisted_python_versions_package', 1, 0, 0)
s   .svnN(   R   t   mktempt   entryt   syst   modulest   copyt   preTestModulest   patht   appendt   childt   makedirst
   setContentt
   svnEntries(   R   t   pkg(    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   setUp   s    
c         C   s:   t  j j   t  j j |  j  t  j j |  j j  d S(   sI   
        Remove the imported modules and sys.path modifications.
        N(   RB   RC   t   cleart   updateRE   RF   t   removeRA   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   tearDown   s    c         C   sV   |  j  j d  j | d  |  j  j d  j |  |  j |  j   j   |  d S(   s   
        Check for the given revision being detected after setting the SVN
        entries text and format version of the test directory structure.
        t   formats   
t   entriesN(   RK   RH   RJ   R+   t
   getVersiont   _getSVNVersion(   R   t   formatVersiont   entriesTextt   expectedRevision(    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   checkSVNFormat  s    c         C   s   d d l  } | j S(   sf   
        Import and retrieve the Version object from our dynamically created
        package.
        iN(   R?   R(   (   R   R?   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyRT     s    c         C   s   |  j  d t d  d S(   sY   
        Verify that version 4 format file will be properly detected and parsed.
        t   4R%   N(   RY   R'   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_detectVersion4  s    c         C   s   |  j  d t d  d S(   sb   
        Verify that version 8 format files will be properly detected and
        parsed.
        t   8R*   N(   RY   R-   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_detectVersion8"  s    c         C   s   |  j  d t d  d S(   sb   
        Verify that version 9 format files will be properly detected and
        parsed.
        t   9R*   N(   RY   R0   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_detectVersion9*  s    c         C   s9   |  j  j d  j t  |  j |  j   j   d  d S(   s  
        Verify that version 10 format files will be properly detected and
        parsed.

        Differing from previous formats, the version 10 format lacks a
        I{format} file and B{only} has the version information on the first
        line of the I{entries} file.
        RS   R*   N(   RK   RH   RJ   R3   R   RT   RU   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_detectVersion102  s    	c         C   s   |  j  d d d  d S(   sY   
        Verify that a new version of SVN will result in the revision 'Unknown'.
        s   some-random-new-versions   ooga booga!t   UnknownN(   RY   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   test_detectUnknownVersion?  s    (   R<   R=   t   __doc__RM   RQ   RY   RT   R[   R]   R_   R`   Rb   (    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyR>      s   				
						(   RB   t	   cStringIOR    t   twisted.python.versionsR   R   R   R   t   twisted.python.filepathR   t   twisted.trialR   R'   R-   R0   R3   t   TestCaseR   R>   (    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/python/test/test_versions.pyt   <module>   s   
		