@@ -218,6 +218,14 @@ def docker():
218218 return APIClient (version = 'auto' )
219219
220220
221+ @pytest .fixture (autouse = True )
222+ def ensure_mysql_verison (request , mysql_tag ):
223+ if request .node .get_marker ('mysql_verison' ):
224+ if request .node .get_marker ('mysql_verison' ).args [0 ] != mysql_tag :
225+ pytest .skip ('Not applicable for '
226+ 'MySQL version: {0}' .format (mysql_tag ))
227+
228+
221229@pytest .fixture (scope = 'session' )
222230def mysql_server (unused_port , docker , session_id , mysql_tag , request ):
223231 if not request .config .option .no_pull :
@@ -295,6 +303,32 @@ def mysql_server(unused_port, docker, session_id, mysql_tag, request):
295303 assert result ['Value' ].startswith ('TLS' ), \
296304 "Not connected to the database with TLS"
297305
306+ # Create Databases
307+ cursor .execute ('CREATE DATABASE test_pymysql '
308+ 'DEFAULT CHARACTER SET utf8 '
309+ 'DEFAULT COLLATE utf8_general_ci;' )
310+ cursor .execute ('CREATE DATABASE test_pymysql2 '
311+ 'DEFAULT CHARACTER SET utf8 '
312+ 'DEFAULT COLLATE utf8_general_ci;' )
313+
314+ # Do MySQL8+ Specific Setup
315+ if mysql_tag in ('8.0' ,):
316+ # Create Users to test SHA256
317+ cursor .execute ('CREATE USER user_sha256 '
318+ 'IDENTIFIED WITH "sha256_password" '
319+ 'BY "pass_sha256"' )
320+ cursor .execute ('CREATE USER nopass_sha256 '
321+ 'IDENTIFIED WITH "sha256_password"' )
322+ cursor .execute ('CREATE USER user_caching_sha2 '
323+ 'IDENTIFIED '
324+ 'WITH "caching_sha2_password" '
325+ 'BY "pass_caching_sha2"' )
326+ cursor .execute ('CREATE USER nopass_caching_sha2 '
327+ 'IDENTIFIED '
328+ 'WITH "caching_sha2_password" '
329+ 'PASSWORD EXPIRE NEVER' )
330+ cursor .execute ('FLUSH PRIVILEGES' )
331+
298332 break
299333 except Exception as err :
300334 time .sleep (delay )
0 commit comments