Skip to content

Commit

Permalink
Fix a bug when using a custom exception with a custom exception messa…
Browse files Browse the repository at this point in the history
…ge. Also remove tests for Python 3.2 and 3.3. (pnpnpn#55)

* Fix a bug in the code when using a custom exception with a custom exception message. Added a test for this condition.

* Fix line spacing lint error.

* Update CI config to remove Python 3.2 and 3.3, which are no longer supported by tox.

* Remove python 3.2 and 3.3 from travis config.

* Bump version number to 0.4.1.

* Also update version number in init file to 0.4.1.
  • Loading branch information
sequoia-hope authored and pnpnpn committed Dec 5, 2018
1 parent 3ad0308 commit 3c4bad7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ sudo: false
python:
- '2.6'
- '2.7'
- '3.2'
- '3.3'
- '3.4'
- '3.5'
- '3.6'
install:
- if [[ $TRAVIS_PYTHON_VERSION == 3.2 ]]; then pip install -U "virtualenv<14.0.0"; fi
- pip install python-coveralls tox tox-travis
script: tox --recreate
after_success:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

setup(
name='timeout-decorator',
version='0.4.0',
version='0.4.1',
description='Timeout decorator',
long_description=long_description,
author='Patrick Ng',
Expand Down
8 changes: 8 additions & 0 deletions tests/test_timeout_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ def f():
f()


def test_timeout_custom_exception_with_message():
@timeout(seconds=1, timeout_exception=RuntimeError, exception_message="Custom fail message")
def f():
time.sleep(2)
with pytest.raises(RuntimeError, match="Custom fail message"):
f()


def test_timeout_default_exception_message():
@timeout(seconds=1)
def f():
Expand Down
2 changes: 1 addition & 1 deletion timeout_decorator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .timeout_decorator import TimeoutError

__title__ = 'timeout_decorator'
__version__ = '0.4.0'
__version__ = '0.4.1'
2 changes: 1 addition & 1 deletion timeout_decorator/timeout_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _raise_exception(exception, exception_message):
if exception_message is None:
raise exception()
else:
raise exception(value=exception_message)
raise exception(exception_message)


def timeout(seconds=None, use_signals=True, timeout_exception=TimeoutError, exception_message=None):
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
distshare={homedir}/.tox/distshare
envlist=py{26,27,32,33,34,35,36}
envlist=py{26,27,34,35,36}
skip_missing_interpreters=true
indexserver=
pypi = https://pypi.python.org/simple
Expand All @@ -10,7 +10,7 @@ commands=
py.test timeout_decorator tests --pep8
deps =
py32: pytest<3.0
py{26,27,33,34,35,36}: pytest>=3.0
py{26,27,34,35,36}: pytest>=3.0
pytest-pep8==1.0.6

[pytest]
Expand Down

0 comments on commit 3c4bad7

Please sign in to comment.