B
    `^                 @   s   d Z ddlmZm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 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}.
    )divisionabsolute_importN)FilePath)NativeStringIO)TestCase)_runrunc               @   s   e Zd Zdd Zdd ZdS )NonCreatedUpdateTestsc                sl   t    _ j   jd}|  |dd  fdd _| _G dd dt}|  _	d S )N
inctestpkgz__init__.pys   
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   L/home/dcms/DCMS/lib/python3.7/site-packages/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>.Datei     N)__name__
__module____qualname__yearmonthr   r   r   r   Date(   s   r   )
r   mktempr   makedirschild
setContentgetcwd
packagedirobject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.
        z_version.pyr
   NFT)
r   
newversionpatchrcpostdevcreate_date_getcwd_prints  """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `python -m incremental.update inctestpkg` 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!   r1   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
t}|  _	d S )NZsrcar
   z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", "NEXT", 0, 0).short()
next_released_version = "inctestpkg NEXT"
z_version.pysh   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3)
__all__ = ["__version__"]
c                  s    j jS )N)r   r   r   )r   r   r   r   n   r   z$MissingTests.setUp.<locals>.<lambda>c               @   s   e Zd ZdZdZdS )z MissingTests.setUp.<locals>.Datei  r   N)r   r   r   r   r   r   r   r   r   r   q   s   r   )
r   r   r   r   r   r   r   r   r   r    )r   r   r   r   )r   r   r!   V   s    


zMissingTests.setUpc             C   sB   g }|  t* tdddddddd| j| j|jd W dQ R X dS )zk
        `incremental.update package --dev` raises and quits if it can't find
        the package.
        r
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   )assertRaises
ValueErrorr   r    r   r,   )r   r0   r   r   r   	test_pathw   s    zMissingTests.test_pathN)r   r   r   r!   r5   r   r   r   r   r2   U   s   !r2   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
t}|  _	d S )Nsrcr
   z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", "NEXT", 0, 0).short()
next_released_version = "inctestpkg NEXT"
z_version.pysh   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3)
__all__ = ["__version__"]
c                  s    j jS )N)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>.Datei  r   N)r   r   r   r   r   r   r   r   r   r      s   r   )
r   r   r   r   r   r   r   r   r   r    )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 )	z
        `incremental.update package --path=<path> --dev` increments the dev
        version of the package on the given path
        r
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys  """
Provides inctestpkg version information.
"""

# This file is auto-generated! Do not edit!
# Use `python -m incremental.update inctestpkg` 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 `python -m incremental.update inctestpkg` to change this file.

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, dev=1)
__all__ = ["__version__"]
)
r   r    r   r,   r-   r   r   r+   r.   r/   )r   r0   r   r   r   r5      sB    

z!CreatedUpdateInSrcTests.test_pathN)r   r   r   r!   r5   r   r   r   r   r6      s   !r6   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S )&CreatedUpdateTestsNc                s|   t    _ j   jd}|  |dd |dd  fdd _| _G dd	 d	t}|  _	d S )
Nr
   z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", "NEXT", 0, 0).short()
next_released_version = "inctestpkg NEXT"
z_version.pysh   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3)
__all__ = ["__version__"]
c                  s    j jS )N)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>.Datei  r   N)r   r   r   r   r   r   r   r   r   r     s   r   )
r   r   r   r   r   r   r   r   r   r    )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 )z
        `incremental.update package --path=<path> --dev` increments the dev
        version of the package on the given path
        r
   NFT)	r   r"   r#   r$   r%   r&   r'   r(   r*   z_version.pys  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, dev=0)
__all__ = ["__version__"]
)
r   r   r   r    r,   r-   r   r+   r.   r/   )r   r0   r   r   r   r5     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
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, dev=0)
__all__ = ["__version__"]
)
r   r    r   r,   r-   r   r   r+   r.   r/   )r   r0   r   r   r   test_dev;  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
   NTF)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 4)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 4).short()
next_released_version = "inctestpkg 1.2.4"
)r   r    r   r,   r.   r   r   r/   )r   r0   r   r   r   
test_patch_  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.
        z_version.pys   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=1, dev=2)
__all__ = ["__version__"]
r
   NTF)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   s  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 4)
__all__ = ["__version__"]
)	r   r   r   r   r    r   r,   r.   r/   )r   r0   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
   NTF)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys!  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 4, release_candidate=1)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 4, release_candidate=1).short()
next_released_version = "inctestpkg 1.2.4.rc1"
)r   r    r   r,   r.   r   r   r/   )r   r0   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.
        z_version.pys   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=1, dev=2)
__all__ = ["__version__"]
r
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   s!  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=2)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 3, release_candidate=2).short()
next_released_version = "inctestpkg 1.2.3.rc2"
)	r   r   r   r   r    r   r,   r.   r/   )r   r0   r   r   r   test_rc_with_existing_rc  s*    
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.
        z_version.pyso   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, dev=2)
__all__ = ["__version__"]
r
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   s"  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 16, 8, 0, release_candidate=1)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short()
next_released_version = "inctestpkg 16.8.0.rc1"
)	r   r   r   r   r    r   r,   r.   r/   )r   r0   r   r   r   test_rc_with_no_rc  s*    
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
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys"  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 16, 8, 0, release_candidate=1)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short()
next_released_version = "inctestpkg 16.8.0.rc1"
s  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 16, 8, 0)
__all__ = ["__version__"]
s   
from incremental import Version
introduced_in = Version("inctestpkg", 16, 8, 0).short()
next_released_version = "inctestpkg 16.8.0"
)r   r    r   r,   r.   r   r   r/   )r   r0   r   r   r   test_full_with_rcK  sJ    

z$CreatedUpdateTests.test_full_with_rcc             C   sV   g }|  t*}tdddddddd| j| j|jd W d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
   NF)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r   z6You need to issue a rc before updating the major/minor)	r3   r4   r   r    r   r,   r.   	exceptionargs)r   r0   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
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, post=0)
__all__ = ["__version__"]
)
r   r    r   r,   r-   r   r   r+   r.   r/   )r   r0   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.
        z_version.pys   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=1, dev=2)
__all__ = ["__version__"]
r
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   s  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, post=0)
__all__ = ["__version__"]
)	r   r   r   r   r    r   r,   r.   r/   )r   r0   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.
        z_version.pysw   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3, post=1, dev=2)
__all__ = ["__version__"]
r
   NFT)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   s  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, post=2)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 2, 3, post=2).short()
next_released_version = "inctestpkg 1.2.3.post2"
)	r   r   r   r   r    r   r,   r.   r/   )r   r0   r   r   r   test_post_with_existing_post  s*    
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 dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W d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1TF)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r   zOnly give --newversion)	r3   r4   r   r    r   r,   r.   r@   rA   )r   r0   rB   r   r   r   test_no_mix_newversion;  sr    z)CreatedUpdateTests.test_no_mix_newversionc             C   s   g }|  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W dQ R X | |jjd d dS )zP
        The `--dev` flag can't be mixed with --patch, --rc, or --post.
        r
   NTF)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r   zOnly give --dev)	r3   r4   r   r    r   r,   r.   r@   rA   )r   r0   rB   r   r   r   test_no_mix_dev  sV    z"CreatedUpdateTests.test_no_mix_devc             C   s  g }|  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W dQ R X | |jjd d |  t*}tdddddddd| j| j|jd W d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
   NTF)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r   zOnly give --createrG   )	r3   r4   r   r    r   r,   r.   r@   rA   )r   r0   rB   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.3.rc1.post2.dev3`, will
        set that version in the package.
        r
   Nz1.2.3.rc1.post2.dev3F)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys0  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 2, 3, release_candidate=1, post=2, dev=3)
__all__ = ["__version__"]
z__init__.pys   
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.3.rc1.post2.dev3"
)r   r    r   r,   r.   r   r   r/   )r   r0   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
   NrG   F)
r   r"   r#   r$   r%   r&   r'   r(   r)   r*   z_version.pys  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 1, 0, 0)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 1, 0, 0).short()
next_released_version = "inctestpkg 1.0.0"
)r   r    r   r,   r.   r   r   r/   )r   r0   r   r   r   test_newversion_bare<  s&    
z'CreatedUpdateTests.test_newversion_bare)r   r   r   ZmaxDiffr!   r5   r9   r:   r;   r<   r=   r>   r?   rC   rD   rE   rF   rH   rI   rJ   rK   rL   r   r   r   r   r8      s&   $$+,,45R$,4F5V0r8   c               @   s$   e Z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
t G  fdddt}| _	d S )Nr7   r
   z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", "NEXT", 0, 0).short()
next_released_version = "inctestpkg NEXT"
z_version.pysh   
from incremental import Version
__version__ = Version("inctestpkg", 1, 2, 3)
__all__ = ["__version__"]
c                  s    j jS )N)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>.Datei  r   N)r   r   r   r   r   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 )Nr   )r   )r   r   r   today  s    z+ScriptTests.setUp.<locals>.DateModule.todayN)r   r   r   rN   r   )r   r   r   
DateModule  s   rO   )
r   r   r   r   r   r   r   r   r   r    )r   r   rO   r   )r   r   r   r!   j  s    


zScriptTests.setUpc          	   C   s\   t  }| td| | t}tdg W dQ R X | |jjd d | 	d|
  dS )zI
        Calling run() with no args will cause it to print help.
        stdoutz--helpNr   zShow this message and exit)r   r#   sysr3   
SystemExitr   r.   r@   rA   assertIngetvalue)r   stringiorB   r   r   r   test_run  s    zScriptTests.test_runc          	   C   s   t  }| td| | td| j | td| j | t}t	ddg W dQ R X | 
|jjd d | d|  | 
| jd	 d
 | 
| jd d dS )zI
        Calling run() with no args will cause it to print help.
        rP   r   r    r
   z--rcNr   zUpdating codebasez_version.pys"  """
Provides inctestpkg version information.
"""

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

from incremental import Version

__version__ = Version("inctestpkg", 16, 8, 0, release_candidate=1)
__all__ = ["__version__"]
z__init__.pys   
from incremental import Version
introduced_in = Version("inctestpkg", 16, 8, 0, release_candidate=1).short()
next_released_version = "inctestpkg 16.8.0.rc1"
)r   r#   rQ   osr   datetimer    r3   rR   r   r.   r@   rA   rS   rT   r   r   r/   )r   rU   rB   r   r   r   test_insufficient_args  s    z"ScriptTests.test_insufficient_argsN)r   r   r   r!   rV   rY   r   r   r   r   rM   i  s   %rM   )__doc__
__future__r   r   rQ   rW   rX   Ztwisted.python.filepathr   Ztwisted.python.compatr   Ztwisted.trial.unittestr   Zincremental.updater   r   r	   r2   r6   r8   rM   r   r   r   r   <module>   s&   @8g      {