1
- # Copyright (c) 2013, 2017 , Oracle and/or its affiliates. All rights reserved.
1
+ # Copyright (c) 2013, 2019 , Oracle and/or its affiliates. All rights reserved.
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License, version 2.0, as
41
41
from mysql .connector import errors
42
42
from mysql .connector .connection import MySQLConnection
43
43
from mysql .connector import pooling
44
+ from mysql .connector .constants import ClientFlag
44
45
45
46
46
47
class PoolingTests (tests .MySQLConnectorTests ):
@@ -73,6 +74,8 @@ def tearDown(self):
73
74
74
75
def test___init__ (self ):
75
76
dbconfig = tests .get_mysql_config ()
77
+ if tests .MYSQL_VERSION < (5 , 7 ):
78
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
76
79
cnxpool = pooling .MySQLConnectionPool (pool_size = 1 , ** dbconfig )
77
80
self .assertRaises (TypeError , pooling .PooledMySQLConnection )
78
81
cnx = MySQLConnection (** dbconfig )
@@ -87,6 +90,8 @@ def test___init__(self):
87
90
88
91
def test___getattr__ (self ):
89
92
dbconfig = tests .get_mysql_config ()
93
+ if tests .MYSQL_VERSION < (5 , 7 ):
94
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
90
95
cnxpool = pooling .MySQLConnectionPool (pool_size = 1 , pool_name = 'test' )
91
96
cnx = MySQLConnection (** dbconfig )
92
97
pcnx = pooling .PooledMySQLConnection (cnxpool , cnx )
@@ -110,6 +115,8 @@ def test___getattr__(self):
110
115
111
116
def test_close (self ):
112
117
dbconfig = tests .get_mysql_config ()
118
+ if tests .MYSQL_VERSION < (5 , 7 ):
119
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
113
120
cnxpool = pooling .MySQLConnectionPool (pool_size = 1 , ** dbconfig )
114
121
115
122
cnxpool ._original_cnx = None
@@ -118,7 +125,8 @@ def dummy_add_connection(self, cnx=None):
118
125
self ._original_cnx = cnx
119
126
cnxpool .add_connection = dummy_add_connection .__get__ (
120
127
cnxpool , pooling .MySQLConnectionPool )
121
-
128
+ if tests .MYSQL_VERSION < (5 , 7 ):
129
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
122
130
pcnx = pooling .PooledMySQLConnection (cnxpool ,
123
131
MySQLConnection (** dbconfig ))
124
132
@@ -141,6 +149,8 @@ def tearDown(self):
141
149
142
150
def test___init__ (self ):
143
151
dbconfig = tests .get_mysql_config ()
152
+ if tests .MYSQL_VERSION < (5 , 7 ):
153
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
144
154
self .assertRaises (errors .PoolError , pooling .MySQLConnectionPool )
145
155
146
156
self .assertRaises (AttributeError , pooling .MySQLConnectionPool ,
@@ -180,14 +190,6 @@ def test_pool_name(self):
180
190
cnxpool = pooling .MySQLConnectionPool (pool_name = pool_name )
181
191
self .assertEqual (pool_name , cnxpool .pool_name )
182
192
183
- def test_reset_session (self ):
184
- """Test MySQLConnectionPool.reset_session property"""
185
- cnxpool = pooling .MySQLConnectionPool (pool_name = 'test' ,
186
- pool_reset_session = False )
187
- self .assertFalse (cnxpool .reset_session )
188
- cnxpool ._reset_session = True
189
- self .assertTrue (cnxpool .reset_session )
190
-
191
193
def test_pool_size (self ):
192
194
"""Test MySQLConnectionPool.pool_size property"""
193
195
pool_size = 4
@@ -226,6 +228,8 @@ def test_add_connection(self):
226
228
self .assertRaises (errors .PoolError , cnxpool .add_connection )
227
229
228
230
dbconfig = tests .get_mysql_config ()
231
+ if tests .MYSQL_VERSION < (5 , 7 ):
232
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
229
233
cnxpool = pooling .MySQLConnectionPool (pool_size = 2 , pool_name = 'test' )
230
234
cnxpool .set_config (** dbconfig )
231
235
@@ -258,6 +262,8 @@ def test_add_connection(self):
258
262
259
263
def test_set_config (self ):
260
264
dbconfig = tests .get_mysql_config ()
265
+ if tests .MYSQL_VERSION < (5 , 7 ):
266
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
261
267
cnxpool = pooling .MySQLConnectionPool (pool_name = 'test' )
262
268
263
269
# No configuration changes
@@ -283,6 +289,8 @@ def test_set_config(self):
283
289
284
290
def test_get_connection (self ):
285
291
dbconfig = tests .get_mysql_config ()
292
+ if tests .MYSQL_VERSION < (5 , 7 ):
293
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
286
294
cnxpool = pooling .MySQLConnectionPool (pool_size = 2 , pool_name = 'test' )
287
295
288
296
self .assertRaises (errors .PoolError , cnxpool .get_connection )
@@ -313,6 +321,8 @@ def test_get_connection(self):
313
321
314
322
def test__remove_connections (self ):
315
323
dbconfig = tests .get_mysql_config ()
324
+ if tests .MYSQL_VERSION < (5 , 7 ):
325
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
316
326
cnxpool = pooling .MySQLConnectionPool (
317
327
pool_size = 2 , pool_name = 'test' , ** dbconfig )
318
328
pcnx = cnxpool .get_connection ()
@@ -355,6 +365,8 @@ def test__get_pooled_connection(self):
355
365
356
366
def test_connect (self ):
357
367
dbconfig = tests .get_mysql_config ()
368
+ if tests .MYSQL_VERSION < (5 , 7 ):
369
+ dbconfig ["client_flags" ] = [- ClientFlag .CONNECT_ARGS ]
358
370
cnx = mysql .connector .connect (pool_size = 1 , pool_name = 'ham' , ** dbconfig )
359
371
exp = cnx .connection_id
360
372
cnx .close ()
0 commit comments