diff options
author | INADA Naoki <inada-n@klab.com> | 2012-12-22 13:04:39 +0900 |
---|---|---|
committer | INADA Naoki <inada-n@klab.com> | 2012-12-22 13:08:46 +0900 |
commit | 833b85f1734a1f66ffc105f7272e402d68e661ed (patch) | |
tree | d99bf896085a1112d6f71a09c561437cd5296264 /test/test_except.py | |
parent | 647af23373c502c2b648ccd425686a89808f1599 (diff) | |
parent | 451631a11a5ed4bdd2334f1298b26fc4e9806729 (diff) | |
download | msgpack-python-833b85f1734a1f66ffc105f7272e402d68e661ed.tar.gz |
Merge branch '0.2-maint' (fix #39)
Diffstat (limited to 'test/test_except.py')
-rw-r--r-- | test/test_except.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_except.py b/test/test_except.py index ad02cb6..e142dd6 100644 --- a/test/test_except.py +++ b/test/test_except.py @@ -6,9 +6,28 @@ from msgpack import packb, unpackb import datetime +class DummyException(Exception): + pass + + def test_raise_on_find_unsupported_value(): assert_raises(TypeError, packb, datetime.datetime.now()) + +def test_raise_from_object_hook(): + def hook(obj): + raise DummyException + assert_raises(DummyException, unpackb, packb({}), object_hook=hook) + assert_raises(DummyException, unpackb, packb({'fizz': 'buzz'}), + object_hook=hook) + assert_raises(DummyException, unpackb, packb({'fizz': 'buzz'}), + object_pairs_hook=hook) + assert_raises(DummyException, unpackb, packb({'fizz': {'buzz': 'spam'}}), + object_hook=hook) + assert_raises(DummyException, unpackb, packb({'fizz': {'buzz': 'spam'}}), + object_pairs_hook=hook) + + if __name__ == '__main__': from nose import main main() |