Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test suite #19

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 10 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
sudo: false
language: python

matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 2.7
env: TOXENV=py27-configparser
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: pypy
env: TOXENV=pypy
- python: pypy3
env: TOXENV=pypy3

python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "pypy"
- "pypy3"
install:
- pip install tox-travis
- git config --global user.email "bumpversion-test-git@travis.ci"
- git config --global user.name "Testing Git on Travis CI"
- git --version
- git config --list
- echo -e '[ui]\nusername = Testing Mercurial on Travis CI <bumpversion-test-hg@travis.ci>' > ~/.hgrc
- hg --version
- pip install --upgrade pytest tox

script:
- tox -e $TOXENV
script: tox
53 changes: 22 additions & 31 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@

version: '{build}'

build: off

build: false # Not a C# project
environment:
matrix:
- PYTHON: "C:/Python27"
TOXENV: "py27"

- PYTHON: "C:/Python27"
TOXENV: "py27-configparser"
- TOXENV: py27
- TOXENV: py27-configparser
- TOXENV: py34
- TOXENV: py35
- TOXENV: py36
- TOXENV: pypy
- TOXENV: pypy3

- PYTHON: "C:/Python33"
TOXENV: "py33"

- PYTHON: "C:/Python34"
TOXENV: "py34"

init:
- "ECHO %TOXENV%"
- "ECHO %PYTHON%"
- ps: "ls C:/Python*"

install:
- ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py')
- "%PYTHON%/python.exe C:/get-pip.py"
- "%PYTHON%/Scripts/pip.exe install virtualenv"
- "%PYTHON%/Scripts/pip.exe install tox"
- "%PYTHON%/Scripts/pip.exe install mercurial"
- "%PYTHON%/Scripts/pip.exe install -e ."

# on Windows, Mercurial is available only for Python 2.7
- ps: (new-object net.webclient).DownloadFile('https://bootstrap.pypa.io/get-pip.py', 'C:/get-pip.py')
- C:\Python27\python.exe C:\get-pip.py"
- C:\Python27\Scripts\pip.exe install mercurial
# Install tox (will cover all python versions)
- C:\Python36\python -m pip install -U tox

# prepare git
- 'git config --global user.email "bumpversion-test-git@appveyor.ci"'
- 'git config --global user.name "Testing Git on AppVeyor CI"'
- 'git --version'
- 'git config --list'

# prepare mercurial
- ps: Add-Content $ENV:UserProfile\Mercurial.ini "[ui]`r`nusername = Testing Mercurial on AppVeyor CI <bumpversion-test-hg@appveyor.ci>"
- ps: Write-Host $ENV:UserProfile\Mercurial.ini
- ps: Get-Content $ENV:UserProfile\Mercurial.ini
- 'hg --version'

test_script:
- "%PYTHON%/Scripts/pip.exe --version"
- "%PYTHON%/Scripts/virtualenv.exe --version"
- "%PYTHON%/Scripts/tox.exe --version"
- "%PYTHON%/Scripts/tox.exe -- -v"
- C:\Python36\scripts\tox

cache:
- '%LOCALAPPDATA%\pip\cache'
- '%USERPROFILE%\.cache\pre-commit'
40 changes: 20 additions & 20 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

import os
import pytest
import sys
import logging
import py
import mock

import argparse
import subprocess
from os import curdir, makedirs, chdir, environ
from os.path import join, curdir, dirname
from os import environ
from shlex import split as shlex_split
from textwrap import dedent
from functools import partial
Expand All @@ -32,12 +30,12 @@ def _get_subprocess_env():
check_output = partial(subprocess.check_output, env=SUBPROCESS_ENV)

xfail_if_no_git = pytest.mark.xfail(
call(["git", "help"]) != 0,
not py.path.local.sysfind("git"),
reason="git is not installed"
)

xfail_if_no_hg = pytest.mark.xfail(
call(["hg", "help"]) != 0,
not py.path.local.sysfind("hg"),
reason="hg is not installed"
)

Expand Down Expand Up @@ -156,7 +154,7 @@ def test_usage_string_fork(tmpdir, capsys):
try:
out = check_output('bumpversion --help', shell=True, stderr=subprocess.STDOUT).decode('utf-8')
except subprocess.CalledProcessError as e:
out = e.output
out = e.output.decode('utf-8')

if not 'usage: bumpversion [-h]' in out:
print(out)
Expand Down Expand Up @@ -1070,7 +1068,8 @@ def test_complex_info_logging(tmpdir, capsys):
with mock.patch("bumpversion.logger") as logger:
main(['patch'])

# beware of the trailing space (" ") after "serialize =":
# beware of the trailing space (" ") after 2nd "serialize =":
# as some editors remove trailing spaces, space is interpolated
EXPECTED_LOG = dedent("""
info|Reading config file .bumpversion.cfg:|
info|[bumpversion]
Expand Down Expand Up @@ -1099,13 +1098,13 @@ def test_complex_info_logging(tmpdir, capsys):
info|[bumpversion]
files = fileE
current_version = 0.4.1
serialize =
serialize =%(space)s
{major}.{minor}.{patch}
{major}.{minor}
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))?

|
""").strip()
""").strip() % dict(space=" ")

actual_log ="\n".join(_mock_calls_to_string(logger)[4:])

Expand Down Expand Up @@ -1136,7 +1135,8 @@ def test_subjunctive_dry_run_logging(tmpdir, vcs):
with mock.patch("bumpversion.logger") as logger:
main(['patch', '--dry-run'])

# beware of the trailing space (" ") after "serialize =":
# beware of the trailing space (" ") after 2nd "serialize =":
# as some editors remove trailing spaces, space is interpolated
EXPECTED_LOG = dedent("""
info|Reading config file .bumpversion.cfg:|
info|[bumpversion]
Expand Down Expand Up @@ -1170,7 +1170,7 @@ def test_subjunctive_dry_run_logging(tmpdir, vcs):
current_version = 0.8.1
commit = True
tag = True
serialize =
serialize =%(space)s
{major}.{minor}.{patch}
{major}.{minor}
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+))?
Expand All @@ -1181,7 +1181,7 @@ def test_subjunctive_dry_run_logging(tmpdir, vcs):
info|Would add changes in file '.bumpversion.cfg' to Git|
info|Would commit to Git with message 'Bump version: 0.8 \u2192 0.8.1'|
info|Would tag 'v0.8.1' with message 'Bump version: 0.8 \u2192 0.8.1' in Git and not signing|
""").strip()
""").strip() % dict(space=" ")

if vcs == "hg":
EXPECTED_LOG = EXPECTED_LOG.replace("Git", "Mercurial")
Expand Down Expand Up @@ -1240,7 +1240,7 @@ def test_log_commitmessage_if_no_commit_tag_but_usable_vcs(tmpdir, vcs):
current_version = 0.3.4
commit = False
tag = False

|
info|Would prepare Git commit|
info|Would add changes in file 'please_touch_me.txt' to Git|
Expand Down Expand Up @@ -1357,7 +1357,7 @@ def test_optional_value_from_documentation(tmpdir):
serialize =
{num}.{release}
{num}

[bumpversion:part:release]
optional_value = gamma
values =
Expand Down Expand Up @@ -1613,7 +1613,7 @@ def test_search_replace_expanding_changelog(tmpdir, capsys):
* Another old nice feature

"""))

config_content = dedent("""
[bumpversion]
current_version = 8.1.1
Expand Down Expand Up @@ -1718,18 +1718,18 @@ def test_file_specific_config_inherits_parse_serialize(tmpdir):
[bumpversion]
current_version = 14-chocolate
parse = (?P<major>\d+)(\-(?P<flavor>[a-z]+))?
serialize =
serialize =
{major}-{flavor}
{major}

[bumpversion:file:todays_icecream]
serialize =
serialize =
{major}-{flavor}

[bumpversion:file:todays_cake]

[bumpversion:part:flavor]
values =
values =
vanilla
chocolate
strawberry
Expand Down