Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/pymysql/tests/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/pymysql/tests/__pycache__/base.cpython-35.opt-1.pyc



�
V�
�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZGdd�dej	�Z
dS)�N�)�CPYTHONc@s�eZdZejjejje�d�Zejj	e�rge
e��Zej
e�ZWdQRXnHddddddd	d
ddd
diddddddd	digZdd�Zdd�Zdd�Zddd�Zdd�Zdd�ZdS)�PyMySQLTestCasezdatabases.jsonN�hostZ	localhost�user�rootZpasswd�ZdbZtest_pymysqlZuse_unicodeTZlocal_infileZ
test_pymysql2cCsJ|j�}tdd�tjd|�jddd�D��}||kS)z�Return True if the given connection is on the version given or
        greater.

        e.g.::

            if self.mysql_server_is(conn, (5, 6, 4)):
                # do something for MySQL 5.6.4 and above
        css-|]#}|dk	r!t|�ndVqdS)Nr)�int)�.0�dig�r�C/opt/alt/python35/lib/python3.5/site-packages/pymysql/tests/base.py�	<genexpr>%sz2PyMySQLTestCase.mysql_server_is.<locals>.<genexpr>z(\d+)\.(\d+)\.(\d+)�r�)Zget_server_info�tuple�re�match�group)�selfZconnZ
version_tupleZserver_versionZserver_version_tuplerrr
�mysql_server_iss
		(zPyMySQLTestCase.mysql_server_iscCsJg|_x*|jD]}|jjtj|��qW|j|j�dS)N)�connections�	databases�append�pymysqlZconnect�
addCleanup�_teardown_connections)rZparamsrrr
�setUp+s	zPyMySQLTestCase.setUpcCs"x|jD]}|j�q
WdS)N)r�close)r�
connectionrrr
r1sz%PyMySQLTestCase._teardown_connectionscCsx|j�}tj��&tjd�|jd|f�WdQRX|j|�|j�|rt|j|j||�dS)z�create a table.

        Ensures any existing version of that table is first dropped.

        Also adds a cleanup rule to drop the table after the test
        completes.
        �ignorezdrop table if exists `%s`N)�cursor�warnings�catch_warnings�simplefilter�executerr�
drop_table)rr�	tablenameZddlZcleanupr!rrr
�safe_create_table5s



z!PyMySQLTestCase.safe_create_tablec
CsO|j�}tj��&tjd�|jd|f�WdQRX|j�dS)Nr zdrop table if exists `%s`)r!r"r#r$r%r)rrr'r!rrr
r&Gs


zPyMySQLTestCase.drop_tablecCstj�tstj�dS)zfEnsure cycles are collected via gc.

        Runs additional times on non-CPython platforms.

        N)�gcZcollectr)rrrr
�safe_gc_collectNs
zPyMySQLTestCase.safe_gc_collect)�__name__�
__module__�__qualname__�os�path�join�dirname�__file__Zfname�exists�open�f�json�loadrrrrr(r&r*rrrr
r
s!!r)r)r6r.rr"Z	unittest2rZ_compatrZTestCaserrrrr
�<module>s