diff options
author | Sofian Brabez <sbz@6dev.net> | 2016-12-14 20:57:55 +0100 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2017-02-20 14:43:46 -0800 |
commit | a4db55c07cf4924c04ec402c16c0eae7de98e4e8 (patch) | |
tree | 8ac048044d50458a436dcd2d6a6e983cf94c2213 /tests/test_packetizer.py | |
parent | c0c6bd8aadf579ff72c14e631cf92a4bdd6e2531 (diff) |
Avoid PacketizerTest.test_closed_3 to fail on platforms where errno.ETIME
is not defined
This changes define the proper Timer expired error message instead of raising
AttributeError when errno.ETIME is not available on the platform. fixes #862
Diffstat (limited to 'tests/test_packetizer.py')
-rw-r--r-- | tests/test_packetizer.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/test_packetizer.py b/tests/test_packetizer.py index 15a7c93f..a7cac6de 100644 --- a/tests/test_packetizer.py +++ b/tests/test_packetizer.py @@ -101,9 +101,13 @@ class PacketizerTest (unittest.TestCase): import signal class TimeoutError(Exception): - pass + def __init__(self, error_message): + if hasattr(errno, 'ETIME'): + self.message = os.sterror(errno.ETIME) + else: + self.messaage = error_message - def timeout(seconds=1, error_message=os.strerror(errno.ETIME)): + def timeout(seconds=1, error_message='Timer expired'): def decorator(func): def _handle_timeout(signum, frame): raise TimeoutError(error_message) |