1- import asyncio
21import os
32import aiomysql
43from tests ._testutils import BaseTest
54
65
76class AIOPyMySQLTestCase (BaseTest ):
87
9- @asyncio .coroutine
10- def _connect_all (self ):
11- conn1 = yield from aiomysql .connect (loop = self .loop , host = self .host ,
12- port = self .port , user = self .user ,
13- db = self .db ,
14- password = self .password ,
15- use_unicode = True , echo = True )
16- conn2 = yield from aiomysql .connect (loop = self .loop , host = self .host ,
17- port = self .port , user = self .user ,
18- db = self .other_db ,
19- password = self .password ,
20- use_unicode = False , echo = True )
21- conn3 = yield from aiomysql .connect (loop = self .loop , host = self .host ,
22- port = self .port , user = self .user ,
23- db = self .db ,
24- password = self .password ,
25- use_unicode = True , echo = True ,
26- local_infile = True )
8+ async def _connect_all (self ):
9+ conn1 = await aiomysql .connect (loop = self .loop , host = self .host ,
10+ port = self .port , user = self .user ,
11+ db = self .db ,
12+ password = self .password ,
13+ use_unicode = True , echo = True )
14+ conn2 = await aiomysql .connect (loop = self .loop , host = self .host ,
15+ port = self .port , user = self .user ,
16+ db = self .other_db ,
17+ password = self .password ,
18+ use_unicode = False , echo = True )
19+ conn3 = await aiomysql .connect (loop = self .loop , host = self .host ,
20+ port = self .port , user = self .user ,
21+ db = self .db ,
22+ password = self .password ,
23+ use_unicode = True , echo = True ,
24+ local_infile = True )
2725
2826 self .connections = [conn1 , conn2 , conn3 ]
2927
@@ -45,9 +43,9 @@ def tearDown(self):
4543 self .doCleanups ()
4644 super (AIOPyMySQLTestCase , self ).tearDown ()
4745
48- @ asyncio . coroutine
49- def connect ( self , host = None , user = None , password = None ,
50- db = None , use_unicode = True , no_delay = None , port = None , ** kwargs ):
46+ async def connect ( self , host = None , user = None , password = None ,
47+ db = None , use_unicode = True , no_delay = None , port = None ,
48+ ** kwargs ):
5149 if host is None :
5250 host = self .host
5351 if user is None :
@@ -58,18 +56,17 @@ def connect(self, host=None, user=None, password=None,
5856 db = self .db
5957 if port is None :
6058 port = self .port
61- conn = yield from aiomysql .connect (loop = self .loop , host = host ,
62- user = user , password = password ,
63- db = db , use_unicode = use_unicode ,
64- no_delay = no_delay , port = port ,
65- ** kwargs )
59+ conn = await aiomysql .connect (loop = self .loop , host = host ,
60+ user = user , password = password ,
61+ db = db , use_unicode = use_unicode ,
62+ no_delay = no_delay , port = port ,
63+ ** kwargs )
6664 self .addCleanup (conn .close )
6765 return conn
6866
69- @asyncio .coroutine
70- def create_pool (self , host = None , user = None , password = None ,
71- db = None , use_unicode = True , no_delay = None ,
72- port = None , ** kwargs ):
67+ async def create_pool (self , host = None , user = None , password = None ,
68+ db = None , use_unicode = True , no_delay = None ,
69+ port = None , ** kwargs ):
7370 if host is None :
7471 host = self .host
7572 if user is None :
@@ -80,10 +77,10 @@ def create_pool(self, host=None, user=None, password=None,
8077 db = self .db
8178 if port is None :
8279 port = self .port
83- pool = yield from aiomysql .create_pool (loop = self .loop , host = host ,
84- user = user , password = password ,
85- db = db , use_unicode = use_unicode ,
86- no_delay = no_delay , port = port ,
87- ** kwargs )
80+ pool = await aiomysql .create_pool (loop = self .loop , host = host ,
81+ user = user , password = password ,
82+ db = db , use_unicode = use_unicode ,
83+ no_delay = no_delay , port = port ,
84+ ** kwargs )
8885 self .addCleanup (pool .close )
8986 return pool
0 commit comments