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.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�host�	localhost�user�root�passwd��dbZtest_pymysql�use_unicodeT�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�)�get_server_info�tuple�re�match�group)�self�conn�
version_tuple�server_versionZserver_version_tuplerrr�mysql_server_iss
		(zPyMySQLTestCase.mysql_server_iscCsJg|_x*|jD]}|jjtj|��qW|j|j�dS)N)�connections�	databases�append�pymysql�connect�
addCleanup�_teardown_connections)r�paramsrrr�setUp+s	zPyMySQLTestCase.setUpcCs"x|jD]}|j�q
WdS)N)r �close)r�
connectionrrrr&1sz%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�executer)r%�
drop_table)rr*�	tablenameZddl�cleanupr,rrr�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/r0r))rr*r2r,rrrr1Gs


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

        Runs additional times on non-CPython platforms.

        N)�gcZcollectr)rrrr�safe_gc_collectNs
zPyMySQLTestCase.safe_gc_collect)�__name__�
__module__�__qualname__�os�path�join�dirname�__file__�fname�exists�open�f�json�loadr!rr(r&r4r1r6rrrrr
s!!r)r5rCr:rr-Z	unittest2r#�_compatrZTestCaserrrrr�<module>s