blob: 051890b254910d82c5b75b5aad0491a55b019222 [file] [log] [blame]
Mark Slee57cc25e2007-02-28 21:43:54 +00001#!/usr/bin/env python
Nobuaki Sukegawa64b8f6c2015-10-10 02:12:48 +09002# -*- coding: utf-8 -*-
David Reissea2cba82009-03-30 21:35:00 +00003#
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
Jens Geyerd629ea02015-09-23 21:16:50 +020022import glob
23import os
24import sys
Mark Slee57cc25e2007-02-28 21:43:54 +000025import time
Jens Geyerd629ea02015-09-23 21:16:50 +020026import unittest
Mark Slee5299a952007-10-05 00:13:24 +000027from optparse import OptionParser
Mark Slee57cc25e2007-02-28 21:43:54 +000028
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +090029SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__))
30ROOT_DIR = os.path.dirname(os.path.dirname(SCRIPT_DIR))
31DEFAULT_LIBDIR_GLOB = os.path.join(ROOT_DIR, 'lib', 'py', 'build', 'lib.*')
Roger Meierf4eec7a2011-09-11 18:16:21 +000032
Jens Geyerd629ea02015-09-23 21:16:50 +020033
Mark Slee5299a952007-10-05 00:13:24 +000034class AbstractTest(unittest.TestCase):
Mark Slee5299a952007-10-05 00:13:24 +000035 def setUp(self):
David Reissf78ec2b2009-01-31 21:59:32 +000036 if options.http_path:
Bryan Duxbury16066592011-03-22 18:06:04 +000037 self.transport = THttpClient.THttpClient(options.host, port=options.port, path=options.http_path)
Mark Slee5299a952007-10-05 00:13:24 +000038 else:
Bryan Duxbury16066592011-03-22 18:06:04 +000039 if options.ssl:
40 from thrift.transport import TSSLSocket
41 socket = TSSLSocket.TSSLSocket(options.host, options.port, validate=False)
42 else:
43 socket = TSocket.TSocket(options.host, options.port)
David Reissf78ec2b2009-01-31 21:59:32 +000044 # frame or buffer depending upon args
Roger Meier76150722014-05-31 22:22:07 +020045 self.transport = TTransport.TBufferedTransport(socket)
46 if options.trans == 'framed':
David Reissf78ec2b2009-01-31 21:59:32 +000047 self.transport = TTransport.TFramedTransport(socket)
Roger Meier76150722014-05-31 22:22:07 +020048 elif options.trans == 'buffered':
David Reissf78ec2b2009-01-31 21:59:32 +000049 self.transport = TTransport.TBufferedTransport(socket)
Roger Meier76150722014-05-31 22:22:07 +020050 elif options.trans == '':
51 raise AssertionError('Unknown --transport option: %s' % options.trans)
Bryan Duxbury16066592011-03-22 18:06:04 +000052 if options.zlib:
53 self.transport = TZlibTransport.TZlibTransport(self.transport, 9)
Mark Slee5299a952007-10-05 00:13:24 +000054 self.transport.open()
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +090055 protocol = self.get_protocol(self.transport)
jfarrelldbf2bb52014-07-09 23:37:12 -040056 self.client = ThriftTest.Client(protocol)
David Reiss0c90f6f2008-02-06 22:18:40 +000057
Mark Slee5299a952007-10-05 00:13:24 +000058 def tearDown(self):
Mark Slee5299a952007-10-05 00:13:24 +000059 self.transport.close()
Mark Sleefc89d392006-09-04 00:04:39 +000060
Mark Slee5299a952007-10-05 00:13:24 +000061 def testVoid(self):
Jens Geyerd629ea02015-09-23 21:16:50 +020062 print('testVoid')
Mark Slee5299a952007-10-05 00:13:24 +000063 self.client.testVoid()
David Reiss0c90f6f2008-02-06 22:18:40 +000064
Mark Slee5299a952007-10-05 00:13:24 +000065 def testString(self):
Jens Geyerd629ea02015-09-23 21:16:50 +020066 print('testString')
Bryan Duxbury16066592011-03-22 18:06:04 +000067 self.assertEqual(self.client.testString('Python' * 20), 'Python' * 20)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +000068 self.assertEqual(self.client.testString(''), '')
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +090069 s1 = u'\b\t\n/\\\\\r{}:パイソン"'
70 s2 = u"""Afrikaans, Alemannisch, Aragonés, العربية, مصرى,
Nobuaki Sukegawa64b8f6c2015-10-10 02:12:48 +090071 Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška,
72 Беларуская, Беларуская (тарашкевіца), Български, Bamanankan,
73 বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн,
74 Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg,
75 Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English,
76 Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt,
77 Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego,
78 Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski,
79 Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia,
80 Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa,
81 ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар,
82 Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino,
83 Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa
84 Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa
85 Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪
86 Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad,
87 Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو,
88 Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română,
89 Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple
90 English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk,
91 Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog,
92 Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük,
93 Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文,
94 Bân-lâm-gú, 粵語"""
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +090095 if sys.version_info[0] == 2:
96 s1 = s1.encode('utf8')
97 s2 = s2.encode('utf8')
98 self.assertEqual(self.client.testString(s1), s1)
99 self.assertEqual(self.client.testString(s2), s2)
Mark Sleec9676562006-09-05 17:34:52 +0000100
Nobuaki Sukegawaa649e742015-09-21 13:53:25 +0900101 def testBool(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200102 print('testBool')
Nobuaki Sukegawaa649e742015-09-21 13:53:25 +0900103 self.assertEqual(self.client.testBool(True), True)
104 self.assertEqual(self.client.testBool(False), False)
105
Mark Slee5299a952007-10-05 00:13:24 +0000106 def testByte(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200107 print('testByte')
Mark Slee5299a952007-10-05 00:13:24 +0000108 self.assertEqual(self.client.testByte(63), 63)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000109 self.assertEqual(self.client.testByte(-127), -127)
Mark Sleec98d0502006-09-06 02:42:25 +0000110
Mark Slee5299a952007-10-05 00:13:24 +0000111 def testI32(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200112 print('testI32')
Mark Slee5299a952007-10-05 00:13:24 +0000113 self.assertEqual(self.client.testI32(-1), -1)
114 self.assertEqual(self.client.testI32(0), 0)
Mark Sleec9676562006-09-05 17:34:52 +0000115
Mark Slee5299a952007-10-05 00:13:24 +0000116 def testI64(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200117 print('testI64')
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000118 self.assertEqual(self.client.testI64(1), 1)
Mark Slee5299a952007-10-05 00:13:24 +0000119 self.assertEqual(self.client.testI64(-34359738368), -34359738368)
Mark Sleec98d0502006-09-06 02:42:25 +0000120
Mark Slee5299a952007-10-05 00:13:24 +0000121 def testDouble(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200122 print('testDouble')
Mark Slee5299a952007-10-05 00:13:24 +0000123 self.assertEqual(self.client.testDouble(-5.235098235), -5.235098235)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000124 self.assertEqual(self.client.testDouble(0), 0)
125 self.assertEqual(self.client.testDouble(-1), -1)
Nobuaki Sukegawa228b3282015-10-10 03:11:49 +0900126 self.assertEqual(self.client.testDouble(-0.000341012439638598279), -0.000341012439638598279)
Mark Sleec9676562006-09-05 17:34:52 +0000127
Jens Geyerd629ea02015-09-23 21:16:50 +0200128 def testBinary(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200129 print('testBinary')
130 val = bytearray([i for i in range(0, 256)])
131 self.assertEqual(bytearray(self.client.testBinary(bytes(val))), val)
132
Mark Slee5299a952007-10-05 00:13:24 +0000133 def testStruct(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200134 print('testStruct')
Mark Slee5299a952007-10-05 00:13:24 +0000135 x = Xtruct()
136 x.string_thing = "Zero"
137 x.byte_thing = 1
138 x.i32_thing = -3
139 x.i64_thing = -5
140 y = self.client.testStruct(x)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000141 self.assertEqual(y, x)
Mark Sleefc89d392006-09-04 00:04:39 +0000142
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000143 def testNest(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200144 print('testNest')
145 inner = Xtruct(string_thing="Zero", byte_thing=1, i32_thing=-3, i64_thing=-5)
Roger Meier85fb6de2012-11-02 00:05:42 +0000146 x = Xtruct2(struct_thing=inner, byte_thing=0, i32_thing=0)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000147 y = self.client.testNest(x)
148 self.assertEqual(y, x)
149
150 def testMap(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200151 print('testMap')
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900152 x = {0: 1, 1: 2, 2: 3, 3: 4, -1: -2}
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000153 y = self.client.testMap(x)
154 self.assertEqual(y, x)
155
156 def testSet(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200157 print('testSet')
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000158 x = set([8, 1, 42])
159 y = self.client.testSet(x)
160 self.assertEqual(y, x)
161
162 def testList(self):
Jens Geyerd629ea02015-09-23 21:16:50 +0200163 print('testList')
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000164 x = [1, 4, 9, -42]
165 y = self.client.testList(x)
166 self.assertEqual(y, x)
167
168 def testEnum(self):
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900169 print('testEnum')
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000170 x = Numberz.FIVE
171 y = self.client.testEnum(x)
172 self.assertEqual(y, x)
173
174 def testTypedef(self):
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900175 print('testTypedef')
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900176 x = 0xffffffffffffff # 7 bytes of 0xff
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000177 y = self.client.testTypedef(x)
178 self.assertEqual(y, x)
179
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900180 @unittest.skip('Cannot use dict as dict key')
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000181 def testMapMap(self):
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900182 print('testMapMap')
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000183 # does not work: dict() is not a hashable type, so a dict() cannot be used as a key in another dict()
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900184 x = {{1: 10, 2: 20}, {1: 100, 2: 200, 3: 300}, {1: 1000, 2: 2000, 3: 3000, 4: 4000}}
185 y = self.client.testMapMap(x)
186 self.assertEqual(y, x)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000187
188 def testMulti(self):
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900189 print('testMulti')
Roger Meier85fb6de2012-11-02 00:05:42 +0000190 xpected = Xtruct(string_thing='Hello2', byte_thing=74, i32_thing=0xff00ff, i64_thing=0xffffffffd0d0)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000191 y = self.client.testMulti(xpected.byte_thing,
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900192 xpected.i32_thing,
193 xpected.i64_thing,
194 {0: 'abc'},
195 Numberz.FIVE,
196 0xf0f0f0)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000197 self.assertEqual(y, xpected)
Mark Sleec9676562006-09-05 17:34:52 +0000198
Mark Slee5299a952007-10-05 00:13:24 +0000199 def testException(self):
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900200 print('testException')
Mark Slee5299a952007-10-05 00:13:24 +0000201 self.client.testException('Safe')
202 try:
203 self.client.testException('Xception')
204 self.fail("should have gotten exception")
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900205 except Xception as x:
Mark Slee5299a952007-10-05 00:13:24 +0000206 self.assertEqual(x.errorCode, 1001)
207 self.assertEqual(x.message, 'Xception')
Roger Meier61188a42011-11-01 21:03:33 +0000208 # TODO ensure same behavior for repr within generated python variants
Roger Meierf4eec7a2011-09-11 18:16:21 +0000209 # ensure exception's repr method works
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900210 # x_repr = repr(x)
211 # self.assertEqual(x_repr, 'Xception(errorCode=1001, message=\'Xception\')')
Mark Sleec9676562006-09-05 17:34:52 +0000212
David Reissbcaa2ad2008-06-10 22:55:26 +0000213 try:
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900214 self.client.testException('TException')
215 self.fail("should have gotten exception")
216 except TException as x:
David Reissbcaa2ad2008-06-10 22:55:26 +0000217 pass
218
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900219 # Should not throw
220 self.client.testException('success')
221
222 def testMultiException(self):
223 print('testMultiException')
224 try:
225 self.client.testMultiException('Xception', 'ignore')
226 except Xception as ex:
227 self.assertEqual(ex.errorCode, 1001)
228 self.assertEqual(ex.message, 'This is an Xception')
229
230 try:
231 self.client.testMultiException('Xception2', 'ignore')
232 except Xception2 as ex:
233 self.assertEqual(ex.errorCode, 2002)
234 self.assertEqual(ex.struct_thing.string_thing, 'This is an Xception2')
235
236 y = self.client.testMultiException('success', 'foobar')
237 self.assertEqual(y.string_thing, 'foobar')
238
David Reiss6ce401d2009-03-24 20:01:58 +0000239 def testOneway(self):
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900240 print('testOneway')
David Reissdb893b62008-02-18 02:11:48 +0000241 start = time.time()
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900242 self.client.testOneway(1) # type is int, not float
David Reissdb893b62008-02-18 02:11:48 +0000243 end = time.time()
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000244 self.assertTrue(end - start < 3,
David Reiss6ce401d2009-03-24 20:01:58 +0000245 "oneway sleep took %f sec" % (end - start))
Roger Meier76150722014-05-31 22:22:07 +0200246
Todd Lipconf5dea4c2009-12-03 01:18:44 +0000247 def testOnewayThenNormal(self):
Nobuaki Sukegawa01ede042015-09-29 02:16:53 +0900248 print('testOnewayThenNormal')
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900249 self.client.testOneway(1) # type is int, not float
Todd Lipconf5dea4c2009-12-03 01:18:44 +0000250 self.assertEqual(self.client.testString('Python'), 'Python')
David Reissdb893b62008-02-18 02:11:48 +0000251
Roger Meier879cab22014-05-03 17:51:21 +0200252
Mark Slee5299a952007-10-05 00:13:24 +0000253class NormalBinaryTest(AbstractTest):
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900254 def get_protocol(self, transport):
255 return TBinaryProtocol.TBinaryProtocolFactory().getProtocol(transport)
Mark Sleefc89d392006-09-04 00:04:39 +0000256
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900257
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000258class CompactTest(AbstractTest):
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900259 def get_protocol(self, transport):
260 return TCompactProtocol.TCompactProtocolFactory().getProtocol(transport)
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000261
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900262
Roger Meier85fb6de2012-11-02 00:05:42 +0000263class JSONTest(AbstractTest):
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900264 def get_protocol(self, transport):
265 return TJSONProtocol.TJSONProtocolFactory().getProtocol(transport)
Roger Meier85fb6de2012-11-02 00:05:42 +0000266
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900267
Mark Slee5299a952007-10-05 00:13:24 +0000268class AcceleratedBinaryTest(AbstractTest):
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900269 def get_protocol(self, transport):
270 return TBinaryProtocol.TBinaryProtocolAcceleratedFactory().getProtocol(transport)
Mark Sleea3302652006-10-25 19:03:32 +0000271
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900272
David Reiss9ff3b9d2008-02-15 01:10:23 +0000273def suite():
274 suite = unittest.TestSuite()
275 loader = unittest.TestLoader()
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900276 if options.proto == 'binary': # look for --proto on cmdline
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000277 suite.addTest(loader.loadTestsFromTestCase(NormalBinaryTest))
278 elif options.proto == 'accel':
279 suite.addTest(loader.loadTestsFromTestCase(AcceleratedBinaryTest))
280 elif options.proto == 'compact':
281 suite.addTest(loader.loadTestsFromTestCase(CompactTest))
Roger Meier85fb6de2012-11-02 00:05:42 +0000282 elif options.proto == 'json':
283 suite.addTest(loader.loadTestsFromTestCase(JSONTest))
Bryan Duxbury59d4efd2011-03-21 17:38:22 +0000284 else:
Roger Meier76150722014-05-31 22:22:07 +0200285 raise AssertionError('Unknown protocol given with --protocol: %s' % options.proto)
David Reiss9ff3b9d2008-02-15 01:10:23 +0000286 return suite
Mark Slee5299a952007-10-05 00:13:24 +0000287
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900288
David Reiss74421272008-11-07 23:09:31 +0000289class OwnArgsTestProgram(unittest.TestProgram):
290 def parseArgs(self, argv):
291 if args:
292 self.testNames = args
293 else:
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900294 self.testNames = ([self.defaultTest])
David Reiss74421272008-11-07 23:09:31 +0000295 self.createTests()
296
David Reiss9ff3b9d2008-02-15 01:10:23 +0000297if __name__ == "__main__":
Nobuaki Sukegawaa185d7e2015-11-06 21:24:24 +0900298 parser = OptionParser()
299 parser.add_option('--libpydir', type='string', dest='libpydir',
300 help='include this directory in sys.path for locating library code')
301 parser.add_option('--genpydir', type='string', dest='genpydir',
302 default='gen-py',
303 help='include this directory in sys.path for locating generated code')
304 parser.add_option("--port", type="int", dest="port",
305 help="connect to server at port")
306 parser.add_option("--host", type="string", dest="host",
307 help="connect to server")
308 parser.add_option("--zlib", action="store_true", dest="zlib",
309 help="use zlib wrapper for compressed transport")
310 parser.add_option("--ssl", action="store_true", dest="ssl",
311 help="use SSL for encrypted transport")
312 parser.add_option("--http", dest="http_path",
313 help="Use the HTTP transport with the specified path")
314 parser.add_option('-v', '--verbose', action="store_const",
315 dest="verbose", const=2,
316 help="verbose output")
317 parser.add_option('-q', '--quiet', action="store_const",
318 dest="verbose", const=0,
319 help="minimal output")
320 parser.add_option('--protocol', dest="proto", type="string",
321 help="protocol to use, one of: accel, binary, compact, json")
322 parser.add_option('--transport', dest="trans", type="string",
323 help="transport to use, one of: buffered, framed")
324 parser.set_defaults(framed=False, http_path=None, verbose=1, host='localhost', port=9090, proto='binary')
325 options, args = parser.parse_args()
326
327 sys.path.insert(0, os.path.join(SCRIPT_DIR, options.genpydir))
328 if options.libpydir:
329 sys.path.insert(0, glob.glob(options.libpydir)[0])
330 else:
331 sys.path.insert(0, glob.glob(DEFAULT_LIBDIR_GLOB)[0])
332
333 from ThriftTest import ThriftTest
334 from ThriftTest.ttypes import Xtruct, Xtruct2, Numberz, Xception, Xception2
335 from thrift.Thrift import TException
336 from thrift.transport import TTransport
337 from thrift.transport import TSocket
338 from thrift.transport import THttpClient
339 from thrift.transport import TZlibTransport
340 from thrift.protocol import TBinaryProtocol
341 from thrift.protocol import TCompactProtocol
342 from thrift.protocol import TJSONProtocol
343
Roger Meierf4eec7a2011-09-11 18:16:21 +0000344 OwnArgsTestProgram(defaultTest="suite", testRunner=unittest.TextTestRunner(verbosity=1))