U
    1ÜŸj ‡  ã                   @   s¨   d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZmZmZ G dd„ de	ƒZG d	d
„ d
e	ƒZG dd„ de	ƒZG dd„ de	ƒZG dd„ de	ƒZdS )z"
Tests for L{incremental.update}.
é    N)ÚStringIO)ÚFilePath)ÚTestCase)Ú_mainÚ_runÚrunc                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚNonCreatedUpdateTestsc                    sj   t ˆ  ¡ ƒˆ _ˆ j ¡  ˆ j d¡}| ¡  | d¡ d¡ ‡ fdd„ˆ _|ˆ _G dd„ dƒ}|ƒ ˆ _d S )NÚ
inctestpkgú__init__.pyó‡   
from incremental import Version
introduced_in = Version("inctestpkg", "NEXT", 0, 0).short()
next_released_version = "inctestpkg NEXT"
c                      s   ˆ j jS ©N©ÚsrcdirÚpath© ©Úselfr   úA/tmp/pip-unpacked-wheel-5ydtpfx2/incremental/tests/test_update.pyÚ<lambda>"   ó    z-NonCreatedUpdateTests.setUp.<locals>.<lambda>c                   @   s   e Zd ZdZdZdS )z)NonCreatedUpdateTests.setUp.<locals>.Dateéà  é   N©Ú__name__Ú
__module__Ú__qualname__ÚyearÚmonthr   r   r   r   ÚDate%   s   r   ©	r   Úmktempr   ÚmakedirsÚchildÚ
setContentÚgetcwdÚ
packagedirÚdate©r   r%   r   r   r   r   ÚsetUp   s    

ÿzNonCreatedUpdateTests.setUpc                 C   sp   |   | j d¡ ¡ ¡ g }tdddddddd| j| j|jd� |  | j d¡ ¡ ¡ |  	| j d¡ 
¡ d¡ dS )zP
        `incremental update package --create` initialises the version.
        ú_version.pyr	   NFT©
r   Ú
newversionÚpatchÚrcÚpostÚdevÚcreateÚ_dateZ_getcwdÚ_printóñ   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 16, 8, 0)
__all__ = ["__version__"]
)ZassertFalser%   r"   Úexistsr   r&   r$   ÚappendÚ
assertTrueÚassertEqualÚ
getContent©r   Úoutr   r   r   Útest_create+   s(    õþz!NonCreatedUpdateTests.test_createN)r   r   r   r(   r;   r   r   r   r   r      s   r   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚMissingTestsc                    s�   t ˆ  ¡ ƒˆ _ˆ j ¡  ˆ j d¡ ¡  ˆ j d¡ d¡}| ¡  | d¡ d¡ | d¡ d¡ ‡ fdd„ˆ _|ˆ _G d	d
„ d
ƒ}|ƒ ˆ _d S )NZsrcar	   r
   r   r)   óh   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3)
__all__ = ["__version__"]
c                      s   ˆ j jS r   r   r   r   r   r   r   j   r   z$MissingTests.setUp.<locals>.<lambda>c                   @   s   e Zd ZdZdZdS )z MissingTests.setUp.<locals>.Dater   r   Nr   r   r   r   r   r   m   s   r   r   r'   r   r   r   r(   S   s    

ÿ
ÿzMissingTests.setUpc                 C   sB   g }|   t¡�* tdddddddd| j| j|jd� W 5 Q R X dS )zk
        `incremental update package --dev` raises and quits if it can't find
        the package.
        r	   NFTr*   )ÚassertRaisesÚ
ValueErrorr   r&   r$   r5   r9   r   r   r   Ú	test_paths   s    õzMissingTests.test_pathN©r   r   r   r(   r@   r   r   r   r   r<   R   s    r<   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚCreatedUpdateInSrcTestsc                    s�   t ˆ  ¡ ƒˆ _ˆ j ¡  ˆ j d¡ ¡  ˆ j d¡ d¡}| ¡  | d¡ d¡ | d¡ d¡ ‡ fdd„ˆ _|ˆ _G d	d
„ d
ƒ}|ƒ ˆ _d S )NÚsrcr	   r
   r   r)   r=   c                      s   ˆ j jS r   r   r   r   r   r   r   ¡   r   z/CreatedUpdateInSrcTests.setUp.<locals>.<lambda>c                   @   s   e Zd ZdZdZdS )z+CreatedUpdateInSrcTests.setUp.<locals>.Dater   r   Nr   r   r   r   r   r   ¤   s   r   r   r'   r   r   r   r(   Š   s    

ÿ
ÿzCreatedUpdateInSrcTests.setUpc                 C   s¬   g }t dddddddd| j| j|jd� |  | j d¡ ¡ ¡ |  | j d¡ 	¡ d¡ t dddddddd| j| j|jd� |  | j d¡ ¡ ¡ |  | j d¡ 	¡ d¡ dS )	ú†
        `incremental update package --path=<path> --dev` increments the dev
        version of the package on the given path
        r	   NFTr*   r)   ó÷   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, dev=0)
__all__ = ["__version__"]
s÷   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, dev=1)
__all__ = ["__version__"]
©
r   r&   r$   r5   r6   r%   r"   r4   r7   r8   r9   r   r   r   r@   ª   sJ    õþõþz!CreatedUpdateInSrcTests.test_pathNrA   r   r   r   r   rB   ‰   s    rB   c                   @   s¨   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ ZdS )(ÚCreatedUpdateTestsNc                    sz   t ˆ  ¡ ƒˆ _ˆ j ¡  ˆ j d¡}| ¡  | d¡ d¡ | d¡ d¡ ‡ fdd„ˆ _|ˆ _G dd	„ d	ƒ}|ƒ ˆ _d S )
Nr	   r
   r   r)   r=   c                      s   ˆ j jS r   r   r   r   r   r   r     r   z*CreatedUpdateTests.setUp.<locals>.<lambda>c                   @   s   e Zd ZdZdZdS )z&CreatedUpdateTests.setUp.<locals>.Dater   r   Nr   r   r   r   r   r   
  s   r   r   r'   r   r   r   r(   ò   s    

ÿ
ÿzCreatedUpdateTests.setUpc                 C   sZ   g }t d| jjdddddd| j|jd�
 |  | j d¡ ¡ ¡ |  | j d¡ 	¡ d¡ dS )rD   r	   NFT)	r   r+   r,   r-   r.   r/   r0   r1   r2   r)   rE   )
r   r%   r   r&   r5   r6   r"   r4   r7   r8   r9   r   r   r   r@     s$    öþzCreatedUpdateTests.test_pathc                 C   sZ   g }t dddddddd| j| j|jd� |  | j d¡ ¡ ¡ |  | j d¡ 	¡ d¡ dS )zP
        `incremental update package --dev` increments the dev version.
        r	   NFTr*   r)   rE   rF   r9   r   r   r   Útest_dev4  s&    õþzCreatedUpdateTests.test_devc                 C   s\   g }t dddddddd| j| j|jd� |  | j d¡ ¡ d¡ |  | j d¡ ¡ d	¡ dS )
zT
        `incremental.update package --patch` increments the patch version.
        r	   NTFr*   r)   óð   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 4)
__all__ = ["__version__"]
r
   sƒ   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 4).short()
next_released_version = "inctestpkg 1.2.4"
©r   r&   r$   r5   r7   r%   r"   r8   r9   r   r   r   Ú
test_patchX  s,    õþþzCreatedUpdateTests.test_patchc                 C   sV   | j  d¡ d¡ g }tdddddddd| j| j|jd� |  | j  d¡ ¡ d¡ dS )	zŒ
        `incremental update package --patch` increments the patch version, and
        disregards any old prerelease/dev versions.
        r)   ó„   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=1, dev=2)
__all__ = ["__version__"]
r	   NTFr*   rI   ©	r%   r"   r#   r   r&   r$   r5   r7   r8   r9   r   r   r   Ú"test_patch_with_prerelease_and_devƒ  s*    ÿõþz5CreatedUpdateTests.test_patch_with_prerelease_and_devc                 C   s\   g }t dddddddd| j| j|jd� |  | j d¡ ¡ d¡ |  | j d¡ ¡ d	¡ dS )
z‚
        `incremental update package --patch --rc` increments the patch
        version and makes it a release candidate.
        r	   NTFr*   r)   s  """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 4, release_candidate=1)
__all__ = ["__version__"]
r
   s›   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 4, release_candidate=1).short()
next_released_version = "inctestpkg 1.2.4rc1"
rJ   r9   r   r   r   Útest_rc_patch¯  s,    õþþz CreatedUpdateTests.test_rc_patchc                 C   sn   | j  d¡ d¡ g }tdddddddd| j| j|jd� |  | j  d¡ ¡ d¡ |  | j  d	¡ ¡ d
¡ dS )z•
        `incremental update package --rc` increments the rc version if the
        existing version is an rc, and discards any dev version.
        r)   rL   r	   NFTr*   s  """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=2)
__all__ = ["__version__"]
r
   s›   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 3, release_candidate=2).short()
next_released_version = "inctestpkg 1.2.3rc2"
rM   r9   r   r   r   Útest_rc_with_existing_rcÛ  s2    ÿõþþz+CreatedUpdateTests.test_rc_with_existing_rcc                 C   sn   | j  d¡ d¡ g }tdddddddd| j| j|jd� |  | j  d¡ ¡ d¡ |  | j  d	¡ ¡ d
¡ dS )z´
        `incremental update package --rc`, when the package is not a release
        candidate, will issue a new major/minor rc, and disregards the micro
        and dev.
        r)   so   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, dev=2)
__all__ = ["__version__"]
r	   NFTr*   ó  """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 16, 8, 0, release_candidate=1)
__all__ = ["__version__"]
r
   ó�   
from incremental import Version
introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short()
next_released_version = "inctestpkg 16.8.0rc1"
rM   r9   r   r   r   Útest_rc_with_no_rc  s2    ÿõþþz%CreatedUpdateTests.test_rc_with_no_rcc                 C   s°   g }t dddddddd| j| j|jd� |  | j d¡ ¡ d¡ |  | j d¡ ¡ d	¡ t dddddddd| j| j|jd� |  | j d¡ ¡ d
¡ |  | j d¡ ¡ d¡ dS )z›
        `incremental.update package`, when the package is a release
        candidate, will issue the major/minor, sans release candidate or dev.
        r	   NFTr*   r)   rQ   r
   rR   r3   s…   
from incremental import Version
introduced_in = Version("inctestpkg", 16, 8, 0).short()
next_released_version = "inctestpkg 16.8.0"
rJ   r9   r   r   r   Útest_full_with_rcD  sV    õþþ	õþþz$CreatedUpdateTests.test_full_with_rcc                 C   sV   g }|   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ dS )zy
        `incremental.update package`, when the package is NOT a release
        candidate, will raise an error.
        r	   NFr*   r   z6You need to issue a rc before updating the major/minor©	r>   r?   r   r&   r$   r5   r7   Ú	exceptionÚargs©r   r:   Úer   r   r   Útest_full_without_rc–  s&    õ
þz'CreatedUpdateTests.test_full_without_rcc                 C   sZ   g }t dddddddd| j| j|jd� |  | j d¡ ¡ ¡ |  | j d¡ 	¡ d¡ dS )zR
        `incremental.update package --post` increments the post version.
        r	   NFTr*   r)   óø   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, post=0)
__all__ = ["__version__"]
rF   r9   r   r   r   Ú	test_post°  s&    õþzCreatedUpdateTests.test_postc                 C   sV   | j  d¡ d¡ g }tdddddddd| j| j|jd� |  | j  d¡ ¡ d¡ dS )	zŠ
        `incremental.update package --post` increments the post version, and
        disregards any old prerelease/dev versions.
        r)   rL   r	   NFTr*   r[   rM   r9   r   r   r   Ú!test_post_with_prerelease_and_devÔ  s*    ÿõþz4CreatedUpdateTests.test_post_with_prerelease_and_devc                 C   sn   | j  d¡ d¡ g }tdddddddd| j| j|jd� |  | j  d¡ ¡ d¡ |  | j  d	¡ ¡ d
¡ dS )z¢
        `incremental.update package --post` increments the post version if the
        existing version is an postrelease, and discards any dev version.
        r)   sw   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, post=1, dev=2)
__all__ = ["__version__"]
r	   NFTr*   sø   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, post=2)
__all__ = ["__version__"]
r
   s‘   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 3, post=2).short()
next_released_version = "inctestpkg 1.2.3.post2"
rM   r9   r   r   r   Útest_post_with_existing_post   s2    ÿõþþz/CreatedUpdateTests.test_post_with_existing_postc                 C   s@  g }|   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ dS )	zf
        The `--newversion` flag can't be mixed with --patch, --rc, --post,
        or --dev.
        r	   NÚ1TFr*   r   zOnly give --newversionrU   rX   r   r   r   Útest_no_mix_newversion4  sz    õõõõz)CreatedUpdateTests.test_no_mix_newversionc                 C   sò   g }|   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ dS )zP
        The `--dev` flag can't be mixed with --patch, --rc, or --post.
        r	   NTFr*   r   zOnly give --devrU   rX   r   r   r   Útest_no_mix_devz  s\    õõõz"CreatedUpdateTests.test_no_mix_devc                 C   sŽ  g }|   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ |   t¡�*}tdddddddd| j| j|jd� W 5 Q R X |  |jjd d¡ dS )	zp
        The `--create` flag can't be mixed with --patch, --rc, --post,
        --dev, or --newversion.
        r	   NTFr*   r   zOnly give --creater_   rU   rX   r   r   r   Útest_no_mix_create¯  s˜    õõõõõz%CreatedUpdateTests.test_no_mix_createc                 C   s\   g }t dddddddd| j| j|jd� |  | j d¡ ¡ d¡ |  | j d¡ ¡ d	¡ dS )
z~
        `incremental.update package --newversion=1.2.3rc1.post2.dev3`, will
        set that version in the package.
        r	   Nz1.2.3rc1.post2.dev3Fr*   r)   s  """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=1, post=2, dev=3)
__all__ = ["__version__"]
r
   sµ   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 3, release_candidate=1, post=2, dev=3).short()
next_released_version = "inctestpkg 1.2.3rc1.post2.dev3"
rJ   r9   r   r   r   Útest_newversion  s,    õþýz"CreatedUpdateTests.test_newversionc                 C   s\   g }t dddddddd| j| j|jd� |  | j d¡ ¡ d¡ |  | j d¡ ¡ d	¡ dS )
zl
        `incremental.update package --newversion=1`, will set that
        version in the package.
        r	   Nr_   Fr*   r)   sð   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 0, 0)
__all__ = ["__version__"]
r
   sƒ   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 0, 0).short()
next_released_version = "inctestpkg 1.0.0"
rJ   r9   r   r   r   Útest_newversion_bare5  s,    õþþz'CreatedUpdateTests.test_newversion_barec                 C   s\   g }t dddddddd| j| j|jd� |  | j d¡ ¡ d¡ |  | j d¡ ¡ d	¡ dS )
zn
        `incremental.update package --newversion=1.1`, will set that
        version in the package.
        r	   Nz1.1Fr*   r)   sð   """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `incremental` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 1, 0)
__all__ = ["__version__"]
r
   sƒ   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 1, 0).short()
next_released_version = "inctestpkg 1.1.0"
rJ   r9   r   r   r   Ú test_newversion_bare_major_minora  s,    õþþz3CreatedUpdateTests.test_newversion_bare_major_minor)r   r   r   ZmaxDiffr(   r@   rH   rK   rN   rO   rP   rS   rT   rZ   r\   r]   r^   r`   ra   rb   rc   rd   re   r   r   r   r   rG   ï   s(   $$+,,45R$,4F5V0,rG   c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚScriptTestsc                    s¢   t ˆ ¡ ƒˆ_ˆj ¡  ˆj d¡ ¡  ˆj d¡ d¡}| ¡  | d¡ d¡ | d¡ d¡ ‡fdd„ˆ_|ˆ_G d	d
„ d
ƒ‰ G ‡ fdd„dƒ}|ƒ ˆ_d S )NrC   r	   r
   r   r)   r=   c                      s   ˆ j jS r   r   r   r   r   r   r   ¦  r   z#ScriptTests.setUp.<locals>.<lambda>c                   @   s   e Zd ZdZdZdS )zScriptTests.setUp.<locals>.Dater   r   Nr   r   r   r   r   r   ©  s   r   c                       s   e Zd Z‡ fdd„ZdS )z%ScriptTests.setUp.<locals>.DateModulec                    s   ˆ ƒ S r   r   r   ©r   r   r   Útoday®  s    z+ScriptTests.setUp.<locals>.DateModule.todayN)r   r   r   rh   r   rg   r   r   Ú
DateModule­  s   ri   r   )r   r%   ri   r   )r   r   r   r(   �  s     

ÿ
ÿzScriptTests.setUpc              	   C   s\   t ƒ }|  td|¡ |  t¡�}tdgƒ W 5 Q R X |  |jjd d¡ |  	d| 
¡ ¡ dS )zX
        Running `python -m incremental.update --help` causes it to print help.
        Ústdoutz--helpr   zshow this help message and exitN)r   r,   Úsysr>   Ú
SystemExitr   r7   rV   rW   ÚassertInÚgetvalue©r   ÚstringiorY   r   r   r   Ú	test_help³  s    zScriptTests.test_helpc              	   C   s®   t ƒ }|  td|¡ |  td| j¡ |  td| j¡ |  t¡�}t	ddgƒ W 5 Q R X |  
|jjd d¡ |  d| ¡ ¡ |  
| j d¡ ¡ d	¡ |  
| j d
¡ ¡ d¡ dS )zm
        Running `python -m incremental.update inctestpkg --rc` creates
        a release candidate.
        rj   r$   r&   r	   ú--rcr   úUpdating codebaser)   rQ   r
   rR   N)r   r,   rk   Úosr$   Údatetimer&   r>   rl   r   r7   rV   rW   rm   rn   r%   r"   r8   ro   r   r   r   Útest_incrementalDotUpdateÀ  s     þþz%ScriptTests.test_incrementalDotUpdatec                 C   s†   t ƒ }|  td|¡ |  td| j¡ |  td| j¡ tdddgƒ |  d| 	¡ ¡ |  
| j d¡ ¡ d	¡ |  
| j d
¡ ¡ d¡ dS )zc
        Running `incremental update inctestpkg --rc` creates a release
        candidate.
        rj   r$   r&   Úupdater	   rr   rs   r)   rQ   r
   rR   N)r   r,   rk   rt   r$   ru   r&   r   rm   rn   r7   r%   r"   r8   )r   rp   r   r   r   Útest_incrementalUpdateê  s    þþz"ScriptTests.test_incrementalUpdateN)r   r   r   r(   rq   rv   rx   r   r   r   r   rf   Ž  s   $*rf   )Ú__doc__ru   rt   rk   Úior   Ztwisted.python.filepathr   Ztwisted.trial.unittestr   Zincremental.updater   r   r   r   r<   rB   rG   rf   r   r   r   r   Ú<module>   s&   ?7f       &