remove py26, better pre-commit support, cleaner tox

This commit is contained in:
Kent Wills 2016-04-20 10:01:02 -07:00
parent b66adba924
commit 1b7040a432
7 changed files with 31 additions and 38 deletions

View File

@ -1,11 +1,9 @@
language: python
env:
- TOX_ENV=py26
- TOX_ENV=py27
- TOX_ENV=py33
- TOX_ENV=py34
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
install:
- "pip install --use-mirrors tox"
- pip install tox
script:
- tox -e $TOX_ENV
sudo: false
- tox

2
debian/rules vendored
View File

@ -7,7 +7,7 @@ export DH_OPTIONS
dh $@ --with python-virtualenv
override_dh_virtualenv:
dh_virtualenv
dh_virtualenv --python python2.7
# do not call `make clean` as part of packaging
override_dh_auto_clean:

View File

@ -7,7 +7,8 @@ from pytimeparse import timeparse
def timedelta_type(value):
"""Return the :class:`datetime.datetime.DateTime` for a time in the past.
:param value: a string containing a time format supported by :mod:`pytimeparse`
:param value: a string containing a time format supported by
mod:`pytimeparse`
"""
if value is None:
return None

View File

@ -77,18 +77,22 @@ def get_opts(args=None):
parser.add_argument(
'--max-run-time',
type=timedelta_type,
help="Maximum time a container is allows to run. Time may be specified "
"in any pytimeparse supported format.")
help="Maximum time a container is allows to run. Time may "
"be specified in any pytimeparse supported format."
)
parser.add_argument(
'--prefix', action="append", default=[],
help="Only stop containers which match one of the "
"prefix.")
"prefix."
)
parser.add_argument(
'--dry-run', action="store_true",
help="Only log actions, don't stop anything.")
help="Only log actions, don't stop anything."
)
parser.add_argument(
'-t', '--timeout', type=int, default=60,
help="HTTP timeout in seconds for making docker API calls.")
help="HTTP timeout in seconds for making docker API calls."
)
opts = parser.parse_args(args=args)
if not opts.prefix:

View File

@ -54,7 +54,12 @@ def test_has_been_running_since_false(container, earlier_time):
@mock.patch('docker_custodian.docker_autostop.get_opts',
autospec=True)
@mock.patch('docker_custodian.docker_autostop.docker', autospec=True)
def test_main(mock_docker, mock_get_opts, mock_stop_containers, mock_build_matcher):
def test_main(
mock_docker,
mock_get_opts,
mock_stop_containers,
mock_build_matcher
):
mock_get_opts.return_value.timeout = 30
main()
mock_get_opts.assert_called_once_with()

View File

@ -182,7 +182,9 @@ def test_api_call_with_timeout():
docker_gc.api_call(func, id)
func.assert_called_once_with(id)
mock_log.warn.assert_called_once_with('Failed to call remove_image abcd msg')
mock_log.warn.assert_called_once_with(
'Failed to call remove_image abcd msg'
)
def test_api_call_with_api_error():

27
tox.ini
View File

@ -1,30 +1,13 @@
[tox]
envlist = py26,py27,py33,py34
envlist = py27,py33,py34
[testenv]
deps =
-rrequirements.txt
flake8
pytest
mock
pre-commit
pytest
commands =
py.test {posargs:tests}
flake8 .
[testenv:py26]
deps =
-rrequirements.txt
flake8
pytest
mock < 1.1.0
[testenv:install-hooks]
deps =
pre-commit
commands =
pre-commit install
[flake8]
ignore =
exclude = .git/*,.tox/*,debian/*
max_line_length = 85
pre-commit install -f --install-hooks
pre-commit run --all-files