Skip to content

Commit

Permalink
Merge branch 'release-0.9.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucretiel committed Mar 11, 2015
2 parents 98df28a + 46cea49 commit ccfc6d2
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 24 deletions.
23 changes: 14 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
language: python
python:
- "3.3"
- "3.4"

- '3.3'
- '3.4'
install:
- pip install -e .
- pip install coverage pytest-cov coveralls

- pip install -e .
- pip install coverage pytest-cov coveralls wheel pytest-pep8
script:
- sh -x util/test.sh

- sh util/test.sh
after_success:
- coveralls
- coveralls
deploy:
provider: pypi
user: Lucretiel
password:
secure: kLTVnrjyggnqaGnLAi5M02LDGIC/hfQmdFD+2onZVjRyj3EKYvZ/INz9NtIPgMo4ocixe59LPJI40nORm53ifPiKZs0HikRw7Z/ebzqDXsyShlP4alxd35jXglDV+dRF8yT86UxlLYaUWp5JYODcGKZuMpBGqxu6KD2apq1EILc=
on:
tags: true
distributions: sdist bdist_wheel
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def getfile(filename):

setup(
name='autocommand',
version='0.9.5',
version='0.9.6',
py_modules=['autocommand'],
package_dir={'': 'src'},
platforms='any',
Expand Down
10 changes: 5 additions & 5 deletions src/autocommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from io import IOBase


__version__ = '0.9.5'
__version__ = '0.9.6'


_empty = Parameter.empty
Expand Down Expand Up @@ -184,8 +184,8 @@ def _make_parser(main_sig, description, epilog, add_nos):
action='store_const',
dest=action.dest,
const=action.default)
# No need for a default=, as the first action takes
# precedence.
# No need for a default=, as the first action takes
# precedence.
return parser


Expand Down Expand Up @@ -230,11 +230,11 @@ def autocommand(

# If @autocommand is used instead of @autocommand(__name__)
if callable(module):
return autocommand(None,
return autocommand(
description=description,
epilog=epilog,
add_nos=add_nos,
parser=parser) (module)
parser=parser)(module)

def decorator(main):
main_sig = signature(main)
Expand Down
4 changes: 1 addition & 3 deletions test/test_annotation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import autocommand
from inspect import Parameter

import pytest


@pytest.mark.parametrize('annotation, type, description', [
(Parameter.empty, None, None),
(int, int, None),
Expand All @@ -16,5 +16,3 @@ def test_annotation(annotation, type, description):
def test_invalid_annotation():
with pytest.raises(autocommand.AnnotationError):
autocommand._get_type_description(None)


8 changes: 7 additions & 1 deletion test/test_argument_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

from autocommand import _make_argument


def param(**kwargs):
'''
Create a inspect.Parameter with the (default) kind POSITIONAL_OR_KEYWORD
'''
kwargs.setdefault('kind', Parameter.POSITIONAL_OR_KEYWORD)
return Parameter(**kwargs)

Expand Down Expand Up @@ -59,6 +63,7 @@ def param(**kwargs):
{'nargs': '*', 'type': int}),
]


@mark.parametrize('param, kwargs', arg_cases)
def test_make_arguments(param, kwargs):
made_args, made_kwargs = _make_argument(param, set())
Expand Down Expand Up @@ -95,9 +100,10 @@ def test_make_arguments(param, kwargs):
['--a'], {'a', 'A'})
]


@mark.parametrize('param, used, flags, new_used', flag_cases)
def test_flag_creation(param, used, flags, new_used):
#Ensure transitivity: copy the set
# Ensure transitivity: copy the set
used = set(used)
made_args, made_kwargs = _make_argument(param, used)

Expand Down
2 changes: 2 additions & 0 deletions test/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pytest import raises
from functools import wraps


def run_autocmd_tests(*cases):
'''
This decorator wraps up a bunch of test cases for an autocommand function.
Expand Down Expand Up @@ -56,6 +57,7 @@ def test_single_arg(arg1):
def test_int_arg(arg1: int):
return arg1


@run_autocmd_tests(
('', []),
('foo', ['foo']),
Expand Down
5 changes: 3 additions & 2 deletions test/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from unittest.mock import patch
from pytest import raises, mark


# Note: The (int, 1) case is to provide 100% branch coverage
@mark.parametrize('annotation',
[1, (int, 1)])
@mark.parametrize('annotation', [1, (int, 1)])
def test_annotation_error(annotation):
with raises(autocommand.AnnotationError):
@autocommand.autocommand
Expand All @@ -19,6 +19,7 @@ def test_kwarg_error():
def kwarg(**kwargs):
pass


def test_positional_error():
fake_parameter = Parameter(name='arg', kind=Parameter.POSITIONAL_ONLY)
fake_sig = Signature([fake_parameter])
Expand Down
4 changes: 2 additions & 2 deletions test/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from autocommand import autocommand


@pytest.mark.parametrize('module_name',
['__main__', True])
@pytest.mark.parametrize('module_name', ['__main__', True])
def test_name_main(module_name):
'''
Test that applying the autocommand decorator to a function with '__name__'
Expand Down Expand Up @@ -99,6 +98,7 @@ def prog(arg, verbose, quiet):
with pytest.raises(SystemExit):
prog('-v', '-q')


def test_nos():
@autocommand(add_nos=True)
def prog(verbose=False):
Expand Down
10 changes: 9 additions & 1 deletion util/test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#!/bin/sh

exec py.test --cov src --cov-report term-missing --cov-config .coveragerc test
set -ex

pep8 --show-source src test

py.test \
--cov autocommand \
--cov-report term-missing \
--cov-config .coveragerc \
test

0 comments on commit ccfc6d2

Please sign in to comment.