From e5a26a535e82b40085137d8b7338b8a40f727e57 Mon Sep 17 00:00:00 2001 From: inso <insomniak.fr@gmaiL.com> Date: Fri, 20 Oct 2017 08:02:04 +0200 Subject: [PATCH] Test compatibility with aiohttp 2.3.1 --- tests/api/bma/test_blockchain.py | 24 ++++++++++++------------ tests/api/bma/test_network.py | 4 ++-- tests/api/bma/test_tx.py | 6 +++--- tests/api/bma/test_wot.py | 10 +++++----- tests/api/webserver.py | 6 +++--- tests/documents/test_crc_pubkey.py | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/api/bma/test_blockchain.py b/tests/api/bma/test_blockchain.py index feda7d86..e21778df 100644 --- a/tests/api/bma/test_blockchain.py +++ b/tests/api/bma/test_blockchain.py @@ -43,7 +43,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/parameters', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await parameters(connection) @@ -112,7 +112,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/block/100', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await block(connection, 100) @@ -126,7 +126,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/current', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await current(connection) @@ -187,7 +187,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/hardship/8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await hardship(connection, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU") @@ -227,7 +227,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/memberships/8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await memberships(connection, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU") @@ -249,7 +249,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/with/newcomers', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await newcomers(connection) @@ -271,7 +271,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/with/certs', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await certifications(connection) @@ -293,7 +293,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/with/joiners', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await joiners(connection) @@ -315,7 +315,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/with/actives', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await actives(connection) @@ -337,7 +337,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/with/leavers', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await leavers(connection) @@ -460,7 +460,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/with/ud', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await ud(connection) @@ -482,7 +482,7 @@ class Test_BMA_blockchain(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/blockchain/with/tx', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await tx(connection) diff --git a/tests/api/bma/test_network.py b/tests/api/bma/test_network.py index 145b5690..63eeba95 100644 --- a/tests/api/bma/test_network.py +++ b/tests/api/bma/test_network.py @@ -32,7 +32,7 @@ class TestBMANetwork(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/network/peering', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await network.peering(connection) @@ -72,7 +72,7 @@ class TestBMANetwork(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/network/peering/peers', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await network.peers(connection) diff --git a/tests/api/bma/test_tx.py b/tests/api/bma/test_tx.py index fd89afb5..1551bae3 100644 --- a/tests/api/bma/test_tx.py +++ b/tests/api/bma/test_tx.py @@ -128,7 +128,7 @@ class Test_BMA_TX(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/tx/history/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await history(connection, 'pubkey') @@ -142,7 +142,7 @@ class Test_BMA_TX(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/tx/history/pubkey/blocks/0/100', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await blocks(connection, 'pubkey', 0, 100) @@ -181,7 +181,7 @@ class Test_BMA_TX(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/tx/sources/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await sources(connection, 'pubkey') diff --git a/tests/api/bma/test_wot.py b/tests/api/bma/test_wot.py index 0c4b01f6..61801bf4 100644 --- a/tests/api/bma/test_wot.py +++ b/tests/api/bma/test_wot.py @@ -80,7 +80,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/wot/lookup/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await lookup(connection, 'pubkey') @@ -104,7 +104,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/wot/members', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await members(connection) @@ -158,7 +158,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/wot/certifiers-of/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await certifiers_of(connection, 'pubkey') @@ -190,7 +190,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/wot/certifiers-of/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await certifiers_of(connection, 'pubkey') @@ -204,7 +204,7 @@ class Test_BMA_Wot(WebFunctionalSetupMixin, unittest.TestCase): async def go(): _, srv, port, url = await self.create_server('GET', '/wot/certified-by/pubkey', handler) with self.assertRaises(jsonschema.exceptions.ValidationError): - with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession() as session: connection = next(BMAEndpoint("127.0.0.1", None, None, port).conn_handler(session)) await certified_by(connection, 'pubkey') diff --git a/tests/api/webserver.py b/tests/api/webserver.py index d01b2fed..82cd47fc 100644 --- a/tests/api/webserver.py +++ b/tests/api/webserver.py @@ -15,7 +15,7 @@ class WebFunctionalSetupMixin: def tearDown(self): if self.handler: - self.loop.run_until_complete(self.handler.finish_connections()) + self.loop.run_until_complete(self.handler.shutdown()) try: self.loop.stop() self.loop.close() @@ -29,8 +29,8 @@ class WebFunctionalSetupMixin: s.close() return port - async def create_server(self, method, path, handler=None, ssl_ctx=None): - app = web.Application(loop=self.loop) + async def create_server(self, method, path, handler=None, ssl_ctx=None): + app = web.Application() if handler: app.router.add_route(method, path, handler) diff --git a/tests/documents/test_crc_pubkey.py b/tests/documents/test_crc_pubkey.py index 1d65292e..bac3f3e6 100644 --- a/tests/documents/test_crc_pubkey.py +++ b/tests/documents/test_crc_pubkey.py @@ -5,4 +5,4 @@ from duniterpy.documents.crc_pubkey import CRCPubkey class Test_CRCPubkey(unittest.TestCase): def test_from_pubkey(self): crc_pubkey = CRCPubkey.from_pubkey("J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX") - self.assertEquals(crc_pubkey.crc, "KAv") + self.assertEqual(crc_pubkey.crc, "KAv") -- GitLab