MCPcopy Create free account
hub / github.com/apache/thrift / Test

Class Test

test/py/FastbinaryTest.py:111–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109
110
111class Test(object):
112 def __init__(self, fast, slow):
113 self._fast = fast
114 self._slow = slow
115
116 def _check_write(self, o):
117 trans_fast = TTransport.TMemoryBuffer()
118 trans_slow = TTransport.TMemoryBuffer()
119 prot_fast = self._fast(trans_fast, fallback=False)
120 prot_slow = self._slow(trans_slow)
121
122 o.write(prot_fast)
123 o.write(prot_slow)
124 ORIG = trans_slow.getvalue()
125 MINE = trans_fast.getvalue()
126 if ORIG != MINE:
127 print("actual : %s\nexpected: %s" % (repr(MINE), repr(ORIG)))
128 raise Exception('write value mismatch')
129
130 def _check_read(self, o):
131 prot = self._slow(TTransport.TMemoryBuffer())
132 o.write(prot)
133
134 slow_version_binary = prot.trans.getvalue()
135
136 prot = self._fast(
137 TTransport.TMemoryBuffer(slow_version_binary), fallback=False)
138 c = o.__class__()
139 c.read(prot)
140 if c != o:
141 print("actual : ")
142 pprint(repr(c))
143 print("expected: ")
144 pprint(repr(o))
145 raise Exception('read value mismatch')
146
147 prot = self._fast(
148 TTransport.TBufferedTransport(
149 TTransport.TMemoryBuffer(slow_version_binary)), fallback=False)
150 c = o.__class__()
151 c.read(prot)
152 if c != o:
153 print("actual : ")
154 pprint(repr(c))
155 print("expected: ")
156 pprint(repr(o))
157 raise Exception('read value mismatch')
158
159 def do_test(self):
160 self._check_write(HolyMoley())
161 self._check_read(HolyMoley())
162
163 self._check_write(hm)
164 no_set = deepcopy(hm)
165 no_set.contain = set()
166 self._check_read(no_set)
167 self._check_read(hm)
168

Callers 1

do_testFunction · 0.85

Calls

no outgoing calls

Tested by 1

do_testFunction · 0.68