David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 3 | # |
| 4 | # Licensed to the Apache Software Foundation (ASF) under one |
| 5 | # or more contributor license agreements. See the NOTICE file |
| 6 | # distributed with this work for additional information |
| 7 | # regarding copyright ownership. The ASF licenses this file |
| 8 | # to you under the Apache License, Version 2.0 (the |
| 9 | # "License"); you may not use this file except in compliance |
| 10 | # with the License. You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, |
| 15 | # software distributed under the License is distributed on an |
| 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | # KIND, either express or implied. See the License for the |
| 18 | # specific language governing permissions and limitations |
| 19 | # under the License. |
| 20 | # |
| 21 | |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 22 | import sys, glob |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 23 | from optparse import OptionParser |
| 24 | parser = OptionParser() |
| 25 | parser.add_option('--genpydir', type='string', dest='genpydir', default='gen-py') |
| 26 | options, args = parser.parse_args() |
| 27 | del sys.argv[1:] # clean up hack so unittest doesn't complain |
| 28 | sys.path.insert(0, options.genpydir) |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 29 | sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0]) |
| 30 | |
| 31 | from ThriftTest.ttypes import * |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 32 | from DebugProtoTest.ttypes import CompactProtoTestStruct, Empty |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 33 | from thrift.transport import TTransport |
| 34 | from thrift.transport import TSocket |
Roger Meier | ad8154a | 2012-12-18 21:02:16 +0100 | [diff] [blame] | 35 | from thrift.protocol import TBinaryProtocol, TCompactProtocol, TJSONProtocol |
David Reiss | 6acc269 | 2010-02-26 00:56:02 +0000 | [diff] [blame] | 36 | from thrift.TSerialization import serialize, deserialize |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 37 | import unittest |
| 38 | import time |
| 39 | |
| 40 | class AbstractTest(unittest.TestCase): |
| 41 | |
| 42 | def setUp(self): |
David Reiss | 46bb4ae | 2009-01-14 22:34:15 +0000 | [diff] [blame] | 43 | self.v1obj = VersioningTestV1( |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 44 | begin_in_both=12345, |
David Reiss | a528f54 | 2009-03-24 22:48:40 +0000 | [diff] [blame] | 45 | old_string='aaa', |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 46 | end_in_both=54321, |
David Reiss | 46bb4ae | 2009-01-14 22:34:15 +0000 | [diff] [blame] | 47 | ) |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 48 | |
David Reiss | 46bb4ae | 2009-01-14 22:34:15 +0000 | [diff] [blame] | 49 | self.v2obj = VersioningTestV2( |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 50 | begin_in_both=12345, |
| 51 | newint=1, |
| 52 | newbyte=2, |
| 53 | newshort=3, |
| 54 | newlong=4, |
| 55 | newdouble=5.0, |
David Reiss | 46bb4ae | 2009-01-14 22:34:15 +0000 | [diff] [blame] | 56 | newstruct=Bonk(message="Hello!", type=123), |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 57 | newlist=[7,8,9], |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 58 | newset=set([42,1,8]), |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 59 | newmap={1:2,2:3}, |
| 60 | newstring="Hola!", |
| 61 | end_in_both=54321, |
David Reiss | 46bb4ae | 2009-01-14 22:34:15 +0000 | [diff] [blame] | 62 | ) |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 63 | |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 64 | self.bools = Bools(im_true=True, im_false=False) |
| 65 | self.bools_flipped = Bools(im_true=False, im_false=True) |
| 66 | |
| 67 | self.large_deltas = LargeDeltas ( |
| 68 | b1=self.bools, |
| 69 | b10=self.bools_flipped, |
| 70 | b100=self.bools, |
| 71 | check_true=True, |
| 72 | b1000=self.bools_flipped, |
| 73 | check_false=False, |
| 74 | vertwo2000=VersioningTestV2(newstruct=Bonk(message='World!', type=314)), |
| 75 | a_set2500=set(['lazy', 'brown', 'cow']), |
| 76 | vertwo3000=VersioningTestV2(newset=set([2, 3, 5, 7, 11])), |
| 77 | big_numbers=[2**8, 2**16, 2**31-1, -(2**31-1)] |
| 78 | ) |
| 79 | |
| 80 | self.compact_struct = CompactProtoTestStruct( |
| 81 | a_byte = 127, |
| 82 | a_i16=32000, |
| 83 | a_i32=1000000000, |
| 84 | a_i64=0xffffffffff, |
| 85 | a_double=5.6789, |
| 86 | a_string="my string", |
| 87 | true_field=True, |
| 88 | false_field=False, |
| 89 | empty_struct_field=Empty(), |
| 90 | byte_list=[-127, -1, 0, 1, 127], |
| 91 | i16_list=[-1, 0, 1, 0x7fff], |
| 92 | i32_list= [-1, 0, 0xff, 0xffff, 0xffffff, 0x7fffffff], |
| 93 | i64_list=[-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff], |
| 94 | double_list=[0.1, 0.2, 0.3], |
| 95 | string_list=["first", "second", "third"], |
| 96 | boolean_list=[True, True, True, False, False, False], |
| 97 | struct_list=[Empty(), Empty()], |
| 98 | byte_set=set([-127, -1, 0, 1, 127]), |
| 99 | i16_set=set([-1, 0, 1, 0x7fff]), |
| 100 | i32_set=set([1, 2, 3]), |
| 101 | i64_set=set([-1, 0, 0xff, 0xffff, 0xffffff, 0xffffffff, 0xffffffffff, 0xffffffffffff, 0xffffffffffffff, 0x7fffffffffffffff]), |
| 102 | double_set=set([0.1, 0.2, 0.3]), |
| 103 | string_set=set(["first", "second", "third"]), |
| 104 | boolean_set=set([True, False]), |
| 105 | #struct_set=set([Empty()]), # unhashable instance |
| 106 | byte_byte_map={1 : 2}, |
| 107 | i16_byte_map={1 : 1, -1 : 1, 0x7fff : 1}, |
| 108 | i32_byte_map={1 : 1, -1 : 1, 0x7fffffff : 1}, |
| 109 | i64_byte_map={0 : 1, 1 : 1, -1 : 1, 0x7fffffffffffffff : 1}, |
| 110 | double_byte_map={-1.1 : 1, 1.1 : 1}, |
| 111 | string_byte_map={"first" : 1, "second" : 2, "third" : 3, "" : 0}, |
| 112 | boolean_byte_map={True : 1, False: 0}, |
| 113 | byte_i16_map={1 : 1, 2 : -1, 3 : 0x7fff}, |
| 114 | byte_i32_map={1 : 1, 2 : -1, 3 : 0x7fffffff}, |
| 115 | byte_i64_map={1 : 1, 2 : -1, 3 : 0x7fffffffffffffff}, |
| 116 | byte_double_map={1 : 0.1, 2 : -0.1, 3 : 1000000.1}, |
| 117 | byte_string_map={1 : "", 2 : "blah", 3 : "loooooooooooooong string"}, |
| 118 | byte_boolean_map={1 : True, 2 : False}, |
| 119 | #list_byte_map # unhashable |
| 120 | #set_byte_map={set([1, 2, 3]) : 1, set([0, 1]) : 2, set([]) : 0}, # unhashable |
| 121 | #map_byte_map # unhashable |
| 122 | byte_map_map={0 : {}, 1 : {1 : 1}, 2 : {1 : 1, 2 : 2}}, |
| 123 | byte_set_map={0 : set([]), 1 : set([1]), 2 : set([1, 2])}, |
| 124 | byte_list_map={0 : [], 1 : [1], 2 : [1, 2]}, |
| 125 | ) |
| 126 | |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 127 | self.nested_lists_i32x2 = NestedListsI32x2( |
| 128 | [ |
| 129 | [ 1, 1, 2 ], |
| 130 | [ 2, 7, 9 ], |
| 131 | [ 3, 5, 8 ] |
| 132 | ] |
| 133 | ) |
| 134 | |
| 135 | self.nested_lists_i32x3 = NestedListsI32x3( |
| 136 | [ |
| 137 | [ |
| 138 | [ 2, 7, 9 ], |
| 139 | [ 3, 5, 8 ] |
| 140 | ], |
| 141 | [ |
| 142 | [ 1, 1, 2 ], |
| 143 | [ 1, 4, 9 ] |
| 144 | ] |
| 145 | ] |
| 146 | ) |
| 147 | |
| 148 | self.nested_mixedx2 = NestedMixedx2( int_set_list=[ |
| 149 | set([1,2,3]), |
| 150 | set([1,4,9]), |
| 151 | set([1,2,3,5,8,13,21]), |
| 152 | set([-1, 0, 1]) |
| 153 | ], |
| 154 | # note, the sets below are sets of chars, since the strings are iterated |
| 155 | map_int_strset={ 10:set('abc'), 20:set('def'), 30:set('GHI') }, |
| 156 | map_int_strset_list=[ |
| 157 | { 10:set('abc'), 20:set('def'), 30:set('GHI') }, |
| 158 | { 100:set('lmn'), 200:set('opq'), 300:set('RST') }, |
| 159 | { 1000:set('uvw'), 2000:set('wxy'), 3000:set('XYZ') } |
| 160 | ] |
| 161 | ) |
| 162 | |
| 163 | self.nested_lists_bonk = NestedListsBonk( |
| 164 | [ |
| 165 | [ |
| 166 | [ |
| 167 | Bonk(message='inner A first', type=1), |
| 168 | Bonk(message='inner A second', type=1) |
| 169 | ], |
| 170 | [ |
| 171 | Bonk(message='inner B first', type=2), |
| 172 | Bonk(message='inner B second', type=2) |
| 173 | ] |
| 174 | ] |
| 175 | ] |
| 176 | ) |
| 177 | |
| 178 | self.list_bonks = ListBonks( |
| 179 | [ |
| 180 | Bonk(message='inner A', type=1), |
| 181 | Bonk(message='inner B', type=2), |
| 182 | Bonk(message='inner C', type=0) |
| 183 | ] |
| 184 | ) |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 185 | |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 186 | def _serialize(self, obj): |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 187 | trans = TTransport.TMemoryBuffer() |
| 188 | prot = self.protocol_factory.getProtocol(trans) |
| 189 | obj.write(prot) |
| 190 | return trans.getvalue() |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 191 | |
| 192 | def _deserialize(self, objtype, data): |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 193 | prot = self.protocol_factory.getProtocol(TTransport.TMemoryBuffer(data)) |
| 194 | ret = objtype() |
| 195 | ret.read(prot) |
| 196 | return ret |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 197 | |
| 198 | def testForwards(self): |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 199 | obj = self._deserialize(VersioningTestV2, self._serialize(self.v1obj)) |
| 200 | self.assertEquals(obj.begin_in_both, self.v1obj.begin_in_both) |
| 201 | self.assertEquals(obj.end_in_both, self.v1obj.end_in_both) |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 202 | |
| 203 | def testBackwards(self): |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 204 | obj = self._deserialize(VersioningTestV1, self._serialize(self.v2obj)) |
| 205 | self.assertEquals(obj.begin_in_both, self.v2obj.begin_in_both) |
| 206 | self.assertEquals(obj.end_in_both, self.v2obj.end_in_both) |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 207 | |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 208 | def testSerializeV1(self): |
| 209 | obj = self._deserialize(VersioningTestV1, self._serialize(self.v1obj)) |
| 210 | self.assertEquals(obj, self.v1obj) |
| 211 | |
| 212 | def testSerializeV2(self): |
| 213 | obj = self._deserialize(VersioningTestV2, self._serialize(self.v2obj)) |
| 214 | self.assertEquals(obj, self.v2obj) |
| 215 | |
| 216 | def testBools(self): |
| 217 | self.assertNotEquals(self.bools, self.bools_flipped) |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 218 | self.assertNotEquals(self.bools, self.v1obj) |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 219 | obj = self._deserialize(Bools, self._serialize(self.bools)) |
| 220 | self.assertEquals(obj, self.bools) |
| 221 | obj = self._deserialize(Bools, self._serialize(self.bools_flipped)) |
| 222 | self.assertEquals(obj, self.bools_flipped) |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 223 | rep = repr(self.bools) |
| 224 | self.assertTrue(len(rep) > 0) |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 225 | |
| 226 | def testLargeDeltas(self): |
| 227 | # test large field deltas (meaningful in CompactProto only) |
| 228 | obj = self._deserialize(LargeDeltas, self._serialize(self.large_deltas)) |
| 229 | self.assertEquals(obj, self.large_deltas) |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 230 | rep = repr(self.large_deltas) |
| 231 | self.assertTrue(len(rep) > 0) |
| 232 | |
| 233 | def testNestedListsI32x2(self): |
| 234 | obj = self._deserialize(NestedListsI32x2, self._serialize(self.nested_lists_i32x2)) |
| 235 | self.assertEquals(obj, self.nested_lists_i32x2) |
| 236 | rep = repr(self.nested_lists_i32x2) |
| 237 | self.assertTrue(len(rep) > 0) |
| 238 | |
| 239 | def testNestedListsI32x3(self): |
| 240 | obj = self._deserialize(NestedListsI32x3, self._serialize(self.nested_lists_i32x3)) |
| 241 | self.assertEquals(obj, self.nested_lists_i32x3) |
| 242 | rep = repr(self.nested_lists_i32x3) |
| 243 | self.assertTrue(len(rep) > 0) |
| 244 | |
| 245 | def testNestedMixedx2(self): |
| 246 | obj = self._deserialize(NestedMixedx2, self._serialize(self.nested_mixedx2)) |
| 247 | self.assertEquals(obj, self.nested_mixedx2) |
| 248 | rep = repr(self.nested_mixedx2) |
| 249 | self.assertTrue(len(rep) > 0) |
| 250 | |
| 251 | def testNestedListsBonk(self): |
| 252 | obj = self._deserialize(NestedListsBonk, self._serialize(self.nested_lists_bonk)) |
| 253 | self.assertEquals(obj, self.nested_lists_bonk) |
| 254 | rep = repr(self.nested_lists_bonk) |
| 255 | self.assertTrue(len(rep) > 0) |
| 256 | |
| 257 | def testListBonks(self): |
| 258 | obj = self._deserialize(ListBonks, self._serialize(self.list_bonks)) |
| 259 | self.assertEquals(obj, self.list_bonks) |
| 260 | rep = repr(self.list_bonks) |
| 261 | self.assertTrue(len(rep) > 0) |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 262 | |
| 263 | def testCompactStruct(self): |
| 264 | # test large field deltas (meaningful in CompactProto only) |
| 265 | obj = self._deserialize(CompactProtoTestStruct, self._serialize(self.compact_struct)) |
| 266 | self.assertEquals(obj, self.compact_struct) |
Roger Meier | f4eec7a | 2011-09-11 18:16:21 +0000 | [diff] [blame] | 267 | rep = repr(self.compact_struct) |
| 268 | self.assertTrue(len(rep) > 0) |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 269 | |
Konrad Grochowski | d5f3be5 | 2014-10-08 15:32:21 +0200 | [diff] [blame^] | 270 | def testIntegerLimits(self): |
| 271 | bad_values = [CompactProtoTestStruct(a_byte=128), CompactProtoTestStruct(a_byte=-129), |
| 272 | CompactProtoTestStruct(a_i16=32768), CompactProtoTestStruct(a_i16=-32769), |
| 273 | CompactProtoTestStruct(a_i32=2147483648), CompactProtoTestStruct(a_i32=-2147483649), |
| 274 | CompactProtoTestStruct(a_i64=9223372036854775808), CompactProtoTestStruct(a_i64=-9223372036854775809) |
| 275 | ] |
| 276 | |
| 277 | for value in bad_values: |
| 278 | self.assertRaises(Exception, self._serialize, value) |
| 279 | |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 280 | class NormalBinaryTest(AbstractTest): |
| 281 | protocol_factory = TBinaryProtocol.TBinaryProtocolFactory() |
| 282 | |
| 283 | class AcceleratedBinaryTest(AbstractTest): |
| 284 | protocol_factory = TBinaryProtocol.TBinaryProtocolAcceleratedFactory() |
| 285 | |
David Reiss | abafd79 | 2010-09-27 17:28:15 +0000 | [diff] [blame] | 286 | class CompactProtocolTest(AbstractTest): |
| 287 | protocol_factory = TCompactProtocol.TCompactProtocolFactory() |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 288 | |
Roger Meier | ad8154a | 2012-12-18 21:02:16 +0100 | [diff] [blame] | 289 | class JSONProtocolTest(AbstractTest): |
| 290 | protocol_factory = TJSONProtocol.TJSONProtocolFactory() |
| 291 | |
David Reiss | 4c591c9 | 2009-01-31 21:39:25 +0000 | [diff] [blame] | 292 | class AcceleratedFramedTest(unittest.TestCase): |
| 293 | def testSplit(self): |
| 294 | """Test FramedTransport and BinaryProtocolAccelerated |
| 295 | |
| 296 | Tests that TBinaryProtocolAccelerated and TFramedTransport |
| 297 | play nicely together when a read spans a frame""" |
| 298 | |
| 299 | protocol_factory = TBinaryProtocol.TBinaryProtocolAcceleratedFactory() |
| 300 | bigstring = "".join(chr(byte) for byte in range(ord("a"), ord("z")+1)) |
| 301 | |
| 302 | databuf = TTransport.TMemoryBuffer() |
| 303 | prot = protocol_factory.getProtocol(databuf) |
| 304 | prot.writeI32(42) |
| 305 | prot.writeString(bigstring) |
| 306 | prot.writeI16(24) |
| 307 | data = databuf.getvalue() |
| 308 | cutpoint = len(data)/2 |
| 309 | parts = [ data[:cutpoint], data[cutpoint:] ] |
| 310 | |
| 311 | framed_buffer = TTransport.TMemoryBuffer() |
| 312 | framed_writer = TTransport.TFramedTransport(framed_buffer) |
| 313 | for part in parts: |
| 314 | framed_writer.write(part) |
| 315 | framed_writer.flush() |
| 316 | self.assertEquals(len(framed_buffer.getvalue()), len(data) + 8) |
| 317 | |
| 318 | # Recreate framed_buffer so we can read from it. |
| 319 | framed_buffer = TTransport.TMemoryBuffer(framed_buffer.getvalue()) |
| 320 | framed_reader = TTransport.TFramedTransport(framed_buffer) |
| 321 | prot = protocol_factory.getProtocol(framed_reader) |
| 322 | self.assertEqual(prot.readI32(), 42) |
| 323 | self.assertEqual(prot.readString(), bigstring) |
| 324 | self.assertEqual(prot.readI16(), 24) |
| 325 | |
David Reiss | 6acc269 | 2010-02-26 00:56:02 +0000 | [diff] [blame] | 326 | class SerializersTest(unittest.TestCase): |
| 327 | |
| 328 | def testSerializeThenDeserialize(self): |
| 329 | obj = Xtruct2(i32_thing=1, |
| 330 | struct_thing=Xtruct(string_thing="foo")) |
| 331 | |
| 332 | s1 = serialize(obj) |
| 333 | for i in range(10): |
| 334 | self.assertEquals(s1, serialize(obj)) |
| 335 | objcopy = Xtruct2() |
| 336 | deserialize(objcopy, serialize(obj)) |
| 337 | self.assertEquals(obj, objcopy) |
| 338 | |
| 339 | obj = Xtruct(string_thing="bar") |
| 340 | objcopy = Xtruct() |
| 341 | deserialize(objcopy, serialize(obj)) |
| 342 | self.assertEquals(obj, objcopy) |
David Reiss | 4c591c9 | 2009-01-31 21:39:25 +0000 | [diff] [blame] | 343 | |
Bryan Duxbury | df4cffd | 2011-03-15 17:16:09 +0000 | [diff] [blame] | 344 | # test booleans |
| 345 | obj = Bools(im_true=True, im_false=False) |
| 346 | objcopy = Bools() |
| 347 | deserialize(objcopy, serialize(obj)) |
| 348 | self.assertEquals(obj, objcopy) |
| 349 | |
| 350 | # test enums |
| 351 | for num, name in Numberz._VALUES_TO_NAMES.iteritems(): |
| 352 | obj = Bonk(message='enum Numberz value %d is string %s' % (num, name), type=num) |
| 353 | objcopy = Bonk() |
| 354 | deserialize(objcopy, serialize(obj)) |
| 355 | self.assertEquals(obj, objcopy) |
| 356 | |
David Reiss | 4c591c9 | 2009-01-31 21:39:25 +0000 | [diff] [blame] | 357 | |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 358 | def suite(): |
| 359 | suite = unittest.TestSuite() |
| 360 | loader = unittest.TestLoader() |
| 361 | |
| 362 | suite.addTest(loader.loadTestsFromTestCase(NormalBinaryTest)) |
| 363 | suite.addTest(loader.loadTestsFromTestCase(AcceleratedBinaryTest)) |
David Reiss | abafd79 | 2010-09-27 17:28:15 +0000 | [diff] [blame] | 364 | suite.addTest(loader.loadTestsFromTestCase(CompactProtocolTest)) |
Roger Meier | ad8154a | 2012-12-18 21:02:16 +0100 | [diff] [blame] | 365 | suite.addTest(loader.loadTestsFromTestCase(JSONProtocolTest)) |
David Reiss | 4c591c9 | 2009-01-31 21:39:25 +0000 | [diff] [blame] | 366 | suite.addTest(loader.loadTestsFromTestCase(AcceleratedFramedTest)) |
David Reiss | 6acc269 | 2010-02-26 00:56:02 +0000 | [diff] [blame] | 367 | suite.addTest(loader.loadTestsFromTestCase(SerializersTest)) |
David Reiss | 9ff3b9d | 2008-02-15 01:10:23 +0000 | [diff] [blame] | 368 | return suite |
| 369 | |
| 370 | if __name__ == "__main__": |
| 371 | unittest.main(defaultTest="suite", testRunner=unittest.TextTestRunner(verbosity=2)) |