Skip to content

Commit 09a4743

Browse files
committed
Python 3.5
1 parent d05bf0d commit 09a4743

File tree

14 files changed

+212
-261
lines changed

14 files changed

+212
-261
lines changed

_ucoinpy_test/api/bma/test_blockchain.py

Lines changed: 60 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@ def test_parameters(self):
2727
jsonschema.validate(json_sample, Parameters.schema)
2828

2929
def test_parameters_bad(self):
30-
@asyncio.coroutine
31-
def handler(request):
32-
yield from request.read()
30+
async def handler(request):
31+
await request.read()
3332
return web.Response(body=b'{}', content_type='application/json')
3433

35-
@asyncio.coroutine
36-
def go():
37-
_, srv, url = yield from self.create_server('GET', '/', handler)
34+
async def go():
35+
_, srv, url = await self.create_server('GET', '/', handler)
3836
params = Parameters(None)
3937
params.reverse_url = lambda path: url
4038
with self.assertRaises(jsonschema.exceptions.ValidationError):
41-
yield from params.get()
39+
await params.get()
4240

4341
self.loop.run_until_complete(go())
4442

@@ -97,34 +95,30 @@ def test_schema_block_0(self):
9795
jsonschema.validate(json_sample, Current.schema)
9896

9997
def test_block_bad(self):
100-
@asyncio.coroutine
101-
def handler(request):
102-
yield from request.read()
98+
async def handler(request):
99+
await request.read()
103100
return web.Response(body=b'{}', content_type='application/json')
104101

105-
@asyncio.coroutine
106-
def go():
107-
_, srv, url = yield from self.create_server('GET', '/100', handler)
102+
async def go():
103+
_, srv, url = await self.create_server('GET', '/100', handler)
108104
block = Block(None, 100)
109105
block.reverse_url = lambda path: url
110106
with self.assertRaises(jsonschema.exceptions.ValidationError):
111-
yield from block.get()
107+
await block.get()
112108

113109
self.loop.run_until_complete(go())
114110

115111
def test_current_bad(self):
116-
@asyncio.coroutine
117-
def handler(request):
118-
yield from request.read()
112+
async def handler(request):
113+
await request.read()
119114
return web.Response(body=b'{}', content_type='application/json')
120115

121-
@asyncio.coroutine
122-
def go():
123-
_, srv, url = yield from self.create_server('GET', '/', handler)
116+
async def go():
117+
_, srv, url = await self.create_server('GET', '/', handler)
124118
current = Current(None)
125119
current.reverse_url = lambda path: url
126120
with self.assertRaises(jsonschema.exceptions.ValidationError):
127-
yield from current.get()
121+
await current.get()
128122

129123
self.loop.run_until_complete(go())
130124

@@ -175,18 +169,16 @@ def test_schema_hardship(self):
175169
jsonschema.validate(json_sample, Hardship.schema)
176170

177171
def test_hardship_bad(self):
178-
@asyncio.coroutine
179-
def handler(request):
180-
yield from request.read()
172+
async def handler(request):
173+
await request.read()
181174
return web.Response(body=b'{}', content_type='application/json')
182175

183-
@asyncio.coroutine
184-
def go():
185-
_, srv, url = yield from self.create_server('GET', '/fingerprint', handler)
176+
async def go():
177+
_, srv, url = await self.create_server('GET', '/fingerprint', handler)
186178
hardship = Hardship(None, "fingerprint")
187179
hardship.reverse_url = lambda path: url
188180
with self.assertRaises(jsonschema.exceptions.ValidationError):
189-
yield from hardship.get()
181+
await hardship.get()
190182

191183
self.loop.run_until_complete(go())
192184

@@ -215,18 +207,16 @@ def test_schema_membership(self):
215207
jsonschema.validate(json_sample, Membership.schema)
216208

217209
def test_membership_bad(self):
218-
@asyncio.coroutine
219-
def handler(request):
220-
yield from request.read()
210+
async def handler(request):
211+
await request.read()
221212
return web.Response(body=b'{}', content_type='application/json')
222213

223-
@asyncio.coroutine
224-
def go():
225-
_, srv, url = yield from self.create_server('GET', '/pubkey', handler)
214+
async def go():
215+
_, srv, url = await self.create_server('GET', '/pubkey', handler)
226216
membership = Membership(None, "pubkey")
227217
membership.reverse_url = lambda path: url
228218
with self.assertRaises(jsonschema.exceptions.ValidationError):
229-
yield from membership.get()
219+
await membership.get()
230220

231221
self.loop.run_until_complete(go())
232222

@@ -239,18 +229,16 @@ def test_schema_newcomers(self):
239229
jsonschema.validate(json_sample, Newcomers.schema)
240230

241231
def test_newcomers_bad(self):
242-
@asyncio.coroutine
243-
def handler(request):
244-
yield from request.read()
232+
async def handler(request):
233+
await request.read()
245234
return web.Response(body=b'{}', content_type='application/json')
246235

247-
@asyncio.coroutine
248-
def go():
249-
_, srv, url = yield from self.create_server('GET', '/', handler)
236+
async def go():
237+
_, srv, url = await self.create_server('GET', '/', handler)
250238
newcomers = Newcomers(None)
251239
newcomers.reverse_url = lambda path: url
252240
with self.assertRaises(jsonschema.exceptions.ValidationError):
253-
yield from newcomers.get()
241+
await newcomers.get()
254242

255243
self.loop.run_until_complete(go())
256244

@@ -263,18 +251,16 @@ def test_schema_certifications(self):
263251
jsonschema.validate(json_sample, Certifications.schema)
264252

265253
def test_certifications_bad(self):
266-
@asyncio.coroutine
267-
def handler(request):
268-
yield from request.read()
254+
async def handler(request):
255+
await request.read()
269256
return web.Response(body=b'{}', content_type='application/json')
270257

271-
@asyncio.coroutine
272-
def go():
273-
_, srv, url = yield from self.create_server('GET', '/', handler)
258+
async def go():
259+
_, srv, url = await self.create_server('GET', '/', handler)
274260
certs = Certifications(None)
275261
certs.reverse_url = lambda path: url
276262
with self.assertRaises(jsonschema.exceptions.ValidationError):
277-
yield from certs.get()
263+
await certs.get()
278264

279265
self.loop.run_until_complete(go())
280266

@@ -287,18 +273,16 @@ def test_schema_joiners(self):
287273
jsonschema.validate(json_sample, Joiners.schema)
288274

289275
def test_joiners_bad(self):
290-
@asyncio.coroutine
291-
def handler(request):
292-
yield from request.read()
276+
async def handler(request):
277+
await request.read()
293278
return web.Response(body=b'{}', content_type='application/json')
294279

295-
@asyncio.coroutine
296-
def go():
297-
_, srv, url = yield from self.create_server('GET', '/', handler)
280+
async def go():
281+
_, srv, url = await self.create_server('GET', '/', handler)
298282
joiners = Joiners(None)
299283
joiners.reverse_url = lambda path: url
300284
with self.assertRaises(jsonschema.exceptions.ValidationError):
301-
yield from joiners.get()
285+
await joiners.get()
302286

303287
self.loop.run_until_complete(go())
304288

@@ -311,18 +295,16 @@ def test_schema_actives(self):
311295
jsonschema.validate(json_sample, Actives.schema)
312296

313297
def test_actives_bad(self):
314-
@asyncio.coroutine
315-
def handler(request):
316-
yield from request.read()
298+
async def handler(request):
299+
await request.read()
317300
return web.Response(body=b'{}', content_type='application/json')
318301

319-
@asyncio.coroutine
320-
def go():
321-
_, srv, url = yield from self.create_server('GET', '/', handler)
302+
async def go():
303+
_, srv, url = await self.create_server('GET', '/', handler)
322304
actives = Actives(None)
323305
actives.reverse_url = lambda path: url
324306
with self.assertRaises(jsonschema.exceptions.ValidationError):
325-
yield from actives.get()
307+
await actives.get()
326308

327309
self.loop.run_until_complete(go())
328310

@@ -335,18 +317,16 @@ def test_schema_leavers(self):
335317
jsonschema.validate(json_sample, Leavers.schema)
336318

337319
def test_leavers_bad(self):
338-
@asyncio.coroutine
339-
def handler(request):
340-
yield from request.read()
320+
async def handler(request):
321+
await request.read()
341322
return web.Response(body=b'{}', content_type='application/json')
342323

343-
@asyncio.coroutine
344-
def go():
345-
_, srv, url = yield from self.create_server('GET', '/', handler)
324+
async def go():
325+
_, srv, url = await self.create_server('GET', '/', handler)
346326
leavers = Leavers(None)
347327
leavers.reverse_url = lambda path: url
348328
with self.assertRaises(jsonschema.exceptions.ValidationError):
349-
yield from leavers.get()
329+
await leavers.get()
350330

351331
self.loop.run_until_complete(go())
352332

@@ -359,18 +339,16 @@ def test_schema_ud(self):
359339
jsonschema.validate(json_sample, UD.schema)
360340

361341
def test_ud_bad(self):
362-
@asyncio.coroutine
363-
def handler(request):
364-
yield from request.read()
342+
async def handler(request):
343+
await request.read()
365344
return web.Response(body=b'{}', content_type='application/json')
366345

367-
@asyncio.coroutine
368-
def go():
369-
_, srv, url = yield from self.create_server('GET', '/', handler)
346+
async def go():
347+
_, srv, url = await self.create_server('GET', '/', handler)
370348
ud = UD(None)
371349
ud.reverse_url = lambda path: url
372350
with self.assertRaises(jsonschema.exceptions.ValidationError):
373-
yield from ud.get()
351+
await ud.get()
374352

375353
self.loop.run_until_complete(go())
376354

@@ -383,17 +361,15 @@ def test_schema_tx(self):
383361
jsonschema.validate(json_sample, TX.schema)
384362

385363
def test_tx_bad(self):
386-
@asyncio.coroutine
387-
def handler(request):
388-
yield from request.read()
364+
async def handler(request):
365+
await request.read()
389366
return web.Response(body=b'{}', content_type='application/json')
390367

391-
@asyncio.coroutine
392-
def go():
393-
_, srv, url = yield from self.create_server('GET', '/', handler)
368+
async def go():
369+
_, srv, url = await self.create_server('GET', '/', handler)
394370
tx = TX(None)
395371
tx.reverse_url = lambda path: url
396372
with self.assertRaises(jsonschema.exceptions.ValidationError):
397-
yield from tx.get()
373+
await tx.get()
398374

399375
self.loop.run_until_complete(go())

_ucoinpy_test/api/bma/test_network.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ def test_peering(self):
2222
jsonschema.validate(json_sample, Peering.schema)
2323

2424
def test_peering_bad(self):
25-
@asyncio.coroutine
26-
def handler(request):
27-
yield from request.read()
25+
async def handler(request):
26+
await request.read()
2827
return web.Response(body=b'{}', content_type='application/json')
2928

30-
@asyncio.coroutine
31-
def go():
32-
_, srv, url = yield from self.create_server('GET', '/', handler)
29+
async def go():
30+
_, srv, url = await self.create_server('GET', '/', handler)
3331
peering = Peering(None)
3432
peering.reverse_url = lambda path: url
3533
with self.assertRaises(jsonschema.exceptions.ValidationError):
36-
yield from peering.get()
34+
await peering.get()
3735

3836
def test_peers_root(self):
3937
json_sample = {
@@ -62,15 +60,13 @@ def test_peers_leaf(self):
6260
jsonschema.validate(json_sample, Peers.schema)
6361

6462
def test_peers_bad(self):
65-
@asyncio.coroutine
66-
def handler(request):
67-
yield from request.read()
63+
async def handler(request):
64+
await request.read()
6865
return web.Response(body=b'{}', content_type='application/json')
6966

70-
@asyncio.coroutine
71-
def go():
72-
_, srv, url = yield from self.create_server('GET', '/', handler)
67+
async def go():
68+
_, srv, url = await self.create_server('GET', '/', handler)
7369
peers = Peers(None)
7470
peers.reverse_url = lambda path: url
7571
with self.assertRaises(jsonschema.exceptions.ValidationError):
76-
yield from peers.get()
72+
await peers.get()

0 commit comments

Comments
 (0)