summaryrefslogtreecommitdiff
path: root/test3/test_obj.py
diff options
context:
space:
mode:
authorINADA Naoki <songofacandy@gmail.com>2012-06-19 13:55:14 +0900
committerINADA Naoki <songofacandy@gmail.com>2012-06-19 13:55:14 +0900
commit0b38e86534130f625cbea2f9446e8e52ef5f5a06 (patch)
treef2df0546370c82b735725a17b412e16c78ca302f /test3/test_obj.py
parent76f34667a02f461043a70d776ec05fc1f90bd9e9 (diff)
downloadmsgpack-python-0b38e86534130f625cbea2f9446e8e52ef5f5a06.tar.gz
unify tests for py2 and py3
Diffstat (limited to 'test3/test_obj.py')
-rw-r--r--test3/test_obj.py44
1 files changed, 0 insertions, 44 deletions
diff --git a/test3/test_obj.py b/test3/test_obj.py
deleted file mode 100644
index b54021f..0000000
--- a/test3/test_obj.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-# coding: utf-8
-
-from nose import main
-from nose.tools import *
-
-from msgpack import packs, unpacks
-
-def _decode_complex(obj):
- if b'__complex__' in obj:
- return complex(obj[b'real'], obj[b'imag'])
- return obj
-
-def _encode_complex(obj):
- if isinstance(obj, complex):
- return {b'__complex__': True, b'real': 1, b'imag': 2}
- return obj
-
-def test_encode_hook():
- packed = packs([3, 1+2j], default=_encode_complex)
- unpacked = unpacks(packed)
- eq_(unpacked[1], {b'__complex__': True, b'real': 1, b'imag': 2})
-
-def test_decode_hook():
- packed = packs([3, {b'__complex__': True, b'real': 1, b'imag': 2}])
- unpacked = unpacks(packed, object_hook=_decode_complex)
- eq_(unpacked[1], 1+2j)
-
-@raises(ValueError)
-def test_bad_hook():
- packed = packs([3, 1+2j], default=lambda o: o)
- unpacked = unpacks(packed)
-
-def _arr_to_str(arr):
- return ''.join(str(c) for c in arr)
-
-def test_array_hook():
- packed = packs([1,2,3])
- unpacked = unpacks(packed, list_hook=_arr_to_str)
- eq_(unpacked, '123')
-
-if __name__ == '__main__':
- #main()
- test_decode_hook()