diff options
author | Ben Bangert <ben@groovie.org> | 2017-05-31 13:39:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-31 13:39:29 -0700 |
commit | 5c4e0060ea782c0c33b55a0a0383e51923c8d5d9 (patch) | |
tree | 2b79b0de4f0415acec84bec2ddbed5fa076f7268 | |
parent | 2a3e9d19cd0fde7b03ac8c750e2b107353e3e814 (diff) | |
parent | 8a4c19981287ddc31cfb9202c2be4770a172d9a7 (diff) | |
download | kazoo-5c4e0060ea782c0c33b55a0a0383e51923c8d5d9.tar.gz |
Merge pull request #365 from radix/construct-exceptions-with-saner-arguments
construct empty exceptions with no arguments, instead of () and {}
-rw-r--r-- | kazoo/exceptions.py | 5 | ||||
-rw-r--r-- | kazoo/tests/test_exceptions.py | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/kazoo/exceptions.py b/kazoo/exceptions.py index 6f32b4f..eeefe49 100644 --- a/kazoo/exceptions.py +++ b/kazoo/exceptions.py @@ -52,10 +52,7 @@ EXCEPTIONS = defaultdict(_invalid_error_code) def _zookeeper_exception(code): def decorator(klass): - def create(*args, **kwargs): - return klass(args, kwargs) - - EXCEPTIONS[code] = create + EXCEPTIONS[code] = klass klass.code = code return klass diff --git a/kazoo/tests/test_exceptions.py b/kazoo/tests/test_exceptions.py index 154bcb7..eac65c4 100644 --- a/kazoo/tests/test_exceptions.py +++ b/kazoo/tests/test_exceptions.py @@ -20,3 +20,9 @@ class ExceptionsTestCase(TestCase): def test_invalid_code(self): module = self._get() self.assertRaises(RuntimeError, module.EXCEPTIONS.__getitem__, 666) + + def test_exceptions_construction(self): + module = self._get() + exc = module.EXCEPTIONS[-101]() + assert type(exc) is module.NoNodeError + assert exc.args == () |