Detailed tests of bumpversion.py
================================

.. :doctest:
.. :setup: zest.releaser.tests.functional.setup
.. :teardown: zest.releaser.tests.functional.teardown

Several items are prepared for us.

An svn repository:

    >>> repo_url
    'file://TESTREPO'

An svn checkout of a project:

    >>> svnsourcedir
    'TESTTEMP/tha.example-svn'
    >>> import os
    >>> import sys
    >>> os.chdir(svnsourcedir)

Asking input on the prompt is not unittestable unless we use the prepared
testing hack in utils.py:

    >>> from zest.releaser import utils
    >>> utils.TESTMODE = True

Initially there are no tags, and we require them.  In the tests the
error is ugly, but in practice it looks fine, saying no bump is needed.

    >>> from zest.releaser import bumpversion
    >>> bumpversion.main()
    Traceback (most recent call last):
    ...
    RuntimeError: SYSTEM EXIT (code=0)

So first run the fullrelease:

    >>> from zest.releaser import fullrelease
    >>> utils.test_answer_book.set_answers(['', '', '', '2.3.4', '', '', '', '', '', '', ''])
    >>> fullrelease.main()
    Question...
    Question: Enter version [0.1]:
    Our reply: 2.3.4
    ...
    >>> svnhead('CHANGES.txt')
    Changelog of tha.example
    ========================
    <BLANKLINE>
    2.3.5 (unreleased)
    ------------------
    >>> svnhead('setup.py')
    from setuptools import setup, find_packages
    import os.path
    <BLANKLINE>
    version = '2.3.5.dev0'

Try bumpversion again.  The first time we again get an error because
no version bump is needed: our current version is already higher than
the latest tag, and we have no feature or breaking change.  In the
tests it is again ugly, but the exit code is zero, which is good.

    >>> utils.test_answer_book.set_answers(['', '', '', '', '', ''])
    >>> bumpversion.main()
    Traceback (most recent call last):
    ...
    RuntimeError: SYSTEM EXIT (code=0)

Now a feature bump::

    >>> sys.argv[1:] = ['--feature']
    >>> bumpversion.main()
    Checking version bump for feature release.
    Last tag: 2.3.4
    Current version: 2.3.5.dev0
    Question: Enter version [2.4.0.dev0]:
    Our reply: <ENTER>
    Checking data dict
    Question: OK to commit this (Y/n)?
    Our reply: <ENTER>
    >>> svnhead('setup.py')
    from setuptools import setup, find_packages
    import os.path
    <BLANKLINE>
    version = '2.4.0.dev0'
    >>> svnhead('CHANGES.txt')
    Changelog of tha.example
    ========================
    <BLANKLINE>
    2.4.0 (unreleased)
    ------------------

Now a breaking bump, and for this test we explicitly remove the dev marker::

    >>> utils.test_answer_book.set_answers(['3.0.0', ''])
    >>> sys.argv[1:] = ['--breaking']
    >>> bumpversion.main()
    Checking version bump for breaking release.
    Last tag: 2.3.4
    Current version: 2.4.0.dev0
    Question: Enter version [3.0.0.dev0]:
    Our reply: 3.0.0
    Checking data dict
    Question: OK to commit this (Y/n)?
    Our reply: <ENTER>
    >>> svnhead('setup.py')
    from setuptools import setup, find_packages
    import os.path
    <BLANKLINE>
    version = '3.0.0'
    >>> svnhead('CHANGES.txt')
    Changelog of tha.example
    ========================
    <BLANKLINE>
    3.0.0 (unreleased)
    ------------------
