Skip to content

Commit

Permalink
Merge pull request #12 from jantman/updates
Browse files Browse the repository at this point in the history
Test fixes
  • Loading branch information
jantman authored Sep 18, 2020
2 parents bc0cac9 + 3301941 commit 5721f35
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 96 deletions.
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
Changelog
=========

1.1.0 (2020-09-18)
------------------

* Switch GitPython requirement from ``>=2.1.0,<2.2.0`` to ``~=3.1``.
* Correct docs to clarify that this package now needs Python >= 3.5.
* Numerous testing changes:

* Switch tests from deprecated pep8 / pytest-pep8 to pycodestyle / pytest-pycodestyle.
* Code style fixes for using pycodestyle
* Remove py27 and py34 test support
* Update acceptance tests for pip 20

1.0.0 (2019-10-27)
------------------

Expand Down
4 changes: 1 addition & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ tag or commit from a git repo, or has local changes not committed to git.
Requirements
------------

* Python 2.7, or Python 3.4+. Python 3.0-3.2 is not supported. Python 3.3 was supported
but is no longer tested. Python 2.6 might function, but will not return detailed
git information and is not tested.
* Python 3.5+

Usage
-----
Expand Down
6 changes: 0 additions & 6 deletions pytest.ini

This file was deleted.

12 changes: 12 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
[bdist_wheel]
universal=1

[pycodestyle]
exclude = lib/*,lib64/*
max-line-length = 80
ignore = E741,W503,W504

[tool:pytest]
markers =
acceptance: acceptance tests
filterwarnings =
# for py35
ignore::pytest.PytestDeprecationWarning
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ envlist = {py35,py36,py37,py38}-{unit,acceptance},docs
deps =
cov-core
execnet
pep8
pycodestyle
py
pytest
pytest-cache
pytest-cov
pytest-pep8
pytest-pycodestyle
pytest-flakes
mock
freezegun
Expand All @@ -32,8 +32,8 @@ commands =
virtualenv --version
pip --version
pip freeze
unit: py.test -rxs -vv --durations=10 --pep8 --flakes --blockage -m "not acceptance" --cov-report term-missing --cov-report xml --cov-report html --cov-config {toxinidir}/.coveragerc --cov=versionfinder {posargs} versionfinder
acceptance: py.test -rxs -vv --durations=10 --pep8 --flakes --capture=sys -m "acceptance" --cov-report term-missing --cov-report xml --cov-report html --cov-config {toxinidir}/.coveragerc --cov=versionfinder {posargs} versionfinder
unit: py.test -rxs -vv --durations=10 --pycodestyle --flakes --blockage -m "not acceptance" --cov-report term-missing --cov-report xml --cov-report html --cov-config {toxinidir}/.coveragerc --cov=versionfinder {posargs} versionfinder
acceptance: py.test -rxs -vv --durations=10 --capture=sys -m "acceptance" --cov-report term-missing --cov-report xml --cov-report html --cov-config {toxinidir}/.coveragerc --cov=versionfinder {posargs} versionfinder

# always recreate the venv
recreate = True
Expand Down
106 changes: 58 additions & 48 deletions versionfinder/tests/test_acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@
import logging
from versionfinder.versionfinder import chdir
from tempfile import mkdtemp

if sys.version_info >= (3, 3):
from subprocess import DEVNULL
else: # unreachable under 3.4+ - pragma: no cover
DEVNULL = open(os.devnull, 'wb')
from subprocess import DEVNULL

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -131,7 +127,7 @@ def _check_output(args, stderr=None, env=None):
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=stderr, env=env)
(res, err) = p.communicate()
if p.returncode != 0:
print("Command %s OUT/ERR:\n%s", args, res)
print("Command %s OUT/ERR:\n%s\n%s", args, res, err)
raise subprocess.CalledProcessError(p.returncode, args)
if not isinstance(res, type("")):
res = res.decode('utf-8')
Expand Down Expand Up @@ -364,13 +360,15 @@ def _make_git_repo(self, path):
"""create a git repo under path; return the commit"""
print_header("creating git repository in %s" % path)
with chdir(path):
_check_output(['git', 'init', '.'])
_check_output(['git', 'init', '.'], stderr=subprocess.PIPE)
self._set_git_config()
with open('foo', 'w') as fh:
fh.write('foo')
_check_output(['git', 'add', 'foo'])
_check_output(['git', 'add', '-f', 'foo'], stderr=subprocess.PIPE)
self._set_git_config(set_in_travis=True)
_check_output(['git', 'commit', '-m', 'foo'])
_check_output(
['git', 'commit', '-m', 'foo'], stderr=subprocess.PIPE
)
commit = _get_git_commit()
print_header("git repository in %s commit: %s" % (path, commit))
return commit
Expand Down Expand Up @@ -478,7 +476,8 @@ def test_install_local_master(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ file://%s' % test_src,
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand Down Expand Up @@ -686,7 +685,8 @@ def test_install_sdist(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ file://%s' % TEST_TARBALL_PATH,
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand Down Expand Up @@ -740,7 +740,8 @@ def test_install_bdist_wheel(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ file://%s' % TEST_WHEEL_PATH,
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand All @@ -766,7 +767,8 @@ def test_install_bdist_wheel_no_git_binary(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ file://%s' % TEST_WHEEL_PATH,
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand All @@ -779,11 +781,8 @@ def test_install_git(self, capsys, tmpdir):
with capsys.disabled():
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
'git+%s#egg=versionfinder-test-pkg' % (
TEST_GIT_HTTPS_URL
)
])
git_url = 'git+%s#egg=versionfinder-test-pkg' % TEST_GIT_HTTPS_URL
self._pip_install(path, [git_url])
actual = self._get_result(self._get_version(path))
expected = {
'failed': False,
Expand All @@ -794,7 +793,10 @@ def test_install_git(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ git+%s@%s' % (
TEST_GIT_HTTPS_URL, TEST_MASTER_COMMIT
),
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand All @@ -807,11 +809,8 @@ def test_install_git_fork(self, capsys, tmpdir):
with capsys.disabled():
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
'git+%s#egg=versionfinder-test-pkg' % (
TEST_FORK_HTTPS_URL
)
])
git_url = 'git+%s#egg=versionfinder-test-pkg' % TEST_FORK_HTTPS_URL
self._pip_install(path, [git_url])
actual = self._get_result(self._get_version(path))
expected = {
'failed': False,
Expand All @@ -822,7 +821,10 @@ def test_install_git_fork(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ git+%s@%s' % (
TEST_FORK_HTTPS_URL, TEST_MASTER_COMMIT
),
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand All @@ -835,12 +837,11 @@ def test_install_git_commit(self, capsys, tmpdir):
with capsys.disabled():
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
'git+%s@%s#egg=versionfinder-test-pkg' % (
TEST_GIT_HTTPS_URL,
TEST_MASTER_COMMIT
)
])
git_url = 'git+%s@%s#egg=versionfinder-test-pkg' % (
TEST_GIT_HTTPS_URL,
TEST_MASTER_COMMIT
)
self._pip_install(path, [git_url])
actual = self._get_result(self._get_version(path))
expected = {
'failed': False,
Expand All @@ -851,7 +852,10 @@ def test_install_git_commit(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ git+%s@%s' % (
TEST_GIT_HTTPS_URL, TEST_MASTER_COMMIT
),
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand All @@ -864,12 +868,11 @@ def test_install_git_tag(self, capsys, tmpdir):
with capsys.disabled():
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
'git+%s@%s#egg=versionfinder-test-pkg' % (
TEST_GIT_HTTPS_URL,
TEST_TAG
)
])
git_url = 'git+%s@%s#egg=versionfinder-test-pkg' % (
TEST_GIT_HTTPS_URL,
TEST_TAG
)
self._pip_install(path, [git_url])
actual = self._get_result(self._get_version(path))
expected = {
'failed': False,
Expand All @@ -880,7 +883,10 @@ def test_install_git_tag(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ git+%s@%s' % (
TEST_GIT_HTTPS_URL, TEST_TAG_COMMIT
),
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand All @@ -893,12 +899,11 @@ def test_install_git_branch(self, capsys, tmpdir):
with capsys.disabled():
print("\n%s() venv=%s src=%s" % (
inspect.stack()[0][0].f_code.co_name, path, 'git'))
self._pip_install(path, [
'git+%s@%s#egg=versionfinder-test-pkg' % (
TEST_GIT_HTTPS_URL,
TEST_BRANCH
)
])
git_url = 'git+%s@%s#egg=versionfinder-test-pkg' % (
TEST_GIT_HTTPS_URL,
TEST_BRANCH
)
self._pip_install(path, [git_url])
actual = self._get_result(self._get_version(path))
expected = {
'failed': False,
Expand All @@ -909,7 +914,10 @@ def test_install_git_branch(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ git+%s@%s' % (
TEST_GIT_HTTPS_URL, TEST_BRANCH_COMMIT
),
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand Down Expand Up @@ -1186,7 +1194,8 @@ def test_install_sdist_in_git_repo(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ file://%s' % TEST_TARBALL_PATH,
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand All @@ -1212,7 +1221,8 @@ def test_install_wheel_in_git_repo(self, capsys, tmpdir):
'git_is_dirty': None,
'pip_version': TEST_VERSION,
'pip_url': TEST_PROJECT_URL,
'pip_requirement': 'versionfinder-test-pkg==%s' % TEST_VERSION,
'pip_requirement':
'versionfinder-test-pkg @ file://%s' % TEST_WHEEL_PATH,
'pkg_resources_version': TEST_VERSION,
'pkg_resources_url': TEST_PROJECT_URL,
}
Expand Down
12 changes: 1 addition & 11 deletions versionfinder/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@
################################################################################
"""

import sys
from versionfinder import find_version

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, Mock
else:
from unittest.mock import patch, call, Mock
from unittest.mock import patch, call, Mock


class TestFindVersion(object):
Expand Down
16 changes: 4 additions & 12 deletions versionfinder/tests/test_versionfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,19 @@
"""

import pytest
import sys
from pip._vendor.packaging.version import Version
from git import Repo

from versionfinder.versionfinder import (VersionFinder, chdir)
from versionfinder.versioninfo import VersionInfo

from unittest.mock import (
patch, call, DEFAULT, Mock, PropertyMock, MagicMock
)

import logging
logger = logging.getLogger(__name__)

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, call, DEFAULT, Mock, PropertyMock, MagicMock
else:
from unittest.mock import (
patch, call, DEFAULT, Mock, PropertyMock, MagicMock)

pbm = 'versionfinder.versionfinder'
pb = '%s.VersionFinder' % pbm

Expand Down
12 changes: 1 addition & 11 deletions versionfinder/tests/test_versioninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@
################################################################################
"""

import sys
from versionfinder.versioninfo import VersionInfo

# https://code.google.com/p/mock/issues/detail?id=249
# py>=3.4 should use unittest.mock not the mock package on pypi
if (
sys.version_info[0] < 3 or
sys.version_info[0] == 3 and sys.version_info[1] < 4
):
from mock import patch, PropertyMock
else:
from unittest.mock import patch, PropertyMock
from unittest.mock import patch, PropertyMock

pb = 'versionfinder.versioninfo.VersionInfo'

Expand Down
2 changes: 1 addition & 1 deletion versionfinder/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
##################################################################################
"""

VERSION = '1.0.0'
VERSION = '1.1.0'
PROJECT_URL = 'https://github.com/jantman/versionfinder'

0 comments on commit 5721f35

Please sign in to comment.