diff options
author | Josh <joshdunn.uwo@gmail.com> | 2017-06-10 03:55:11 -0400 |
---|---|---|
committer | Josh <joshdunn.uwo@gmail.com> | 2017-06-10 03:55:11 -0400 |
commit | 2179ba6a46218af85628ffe373e5f5472f7c0999 (patch) | |
tree | 00953d86dd625c411990d9715d153f7a5a00be3c | |
parent | 01d10d2d00d3aea0009d52da1641b40c70f925eb (diff) | |
download | timeout-decorator-2179ba6a46218af85628ffe373e5f5472f7c0999.tar.gz |
Travis CI fixes
-rw-r--r-- | tests/test_timeout_decorator.py | 24 | ||||
-rw-r--r-- | timeout_decorator/timeout_decorator.py | 4 |
2 files changed, 15 insertions, 13 deletions
diff --git a/tests/test_timeout_decorator.py b/tests/test_timeout_decorator.py index be6e314..cadaf26 100644 --- a/tests/test_timeout_decorator.py +++ b/tests/test_timeout_decorator.py @@ -87,17 +87,19 @@ def test_timeout_pickle_error(): with pytest.raises(TimeoutError): f() + def test_timeout_custom_exception_message(): - message = "Custom fail message" - @timeout(seconds=1, exception_message=message) - def f(): - time.sleep(2) - with pytest.raises(TimeoutError, match=message): - f() + message = "Custom fail message" + @timeout(seconds=1, exception_message=message) + def f(): + time.sleep(2) + with pytest.raises(TimeoutError, match=message): + f() + def test_timeout_default_exception_message(): - @timeout(seconds=1) - def f(): - time.sleep(2) - with pytest.raises(TimeoutError, match="Timed Out"): - f() + @timeout(seconds=1) + def f(): + time.sleep(2) + with pytest.raises(TimeoutError, match="Timed Out"): + f() diff --git a/timeout_decorator/timeout_decorator.py b/timeout_decorator/timeout_decorator.py index 425f893..f05da0f 100644 --- a/timeout_decorator/timeout_decorator.py +++ b/timeout_decorator/timeout_decorator.py @@ -41,7 +41,7 @@ def _raise_exception(exception, exception_message): If there is no exception message, the default behaviour is maintained. If there is an exception message, the message is passed to the exception with the 'value' keyword. """ - if exception_message == None: + if exception_message is None: raise exception() else: raise exception(value=exception_message) @@ -170,4 +170,4 @@ class _Timeout(object): flag, load = self.__queue.get() if flag: return load - raise load
\ No newline at end of file + raise load |