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__/test_issues.cpython-35.pyc



��W O�@sddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
Z
yddlZejZWne
k
r�YnXdddgZGdd�de	j�ZGd	d�de	j�ZGd
d�de	j�ZdS)�N)�cursors)�	text_type)�base�
TestOldIssues�
TestNewIssues�TestGitHubIssuesc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zej
d�dd��ZdS)rcCs"|jd}|j�}tj��tjd�|jd�WdQRX|jd�z�|jdd�|jd�|jd|j�d�|jd�|jd|j�d�|jd	�|jd|j�d�|jd
�|jt	|j�dt
j
��Wd|jd�XdS)
z2 undefined methods datetime_or_None, date_or_None r�ignorezdrop table if exists issue3Nz?create table issue3 (d date, t time, dt datetime, ts timestamp)z6insert into issue3 (d, t, dt, ts) values (%s,%s,%s,%s)zselect d from issue3zselect t from issue3zselect dt from issue3zselect ts from issue3zdrop table issue3)NNNN)�connections�cursor�warnings�catch_warnings�filterwarnings�execute�assertEqual�fetchone�
assertTrue�
isinstance�datetime)�self�conn�c�r�J/opt/alt/python35/lib/python3.5/site-packages/pymysql/tests/test_issues.py�test_issue_3s"







'zTestOldIssues.test_issue_3cCs�|jd}|j�}tj��tjd�|jd�WdQRX|jd�zA|jd�|jd�|jt|j�dt	j	��Wd|jd�XdS)	z! can't retrieve TIMESTAMP fields rrzdrop table if exists issue4Nz"create table issue4 (ts timestamp)z&insert into issue4 (ts) values (now())zselect ts from issue4zdrop table issue4)
r	r
rrr
rrrrr)rrrrrr�test_issue_4+s





'zTestOldIssues.test_issue_4cCs*|jd}|j�}|jd�dS)z* query on information_schema.tables fails rz'select * from information_schema.tablesN)r	r
r)rZcon�currrr�test_issue_5:s
zTestOldIssues.test_issue_5cCsS|jdj�}d|d<tj|�}|j�}|jd�|j�dS)zP exception: TypeError: ord() expected a character, but string of length 0 found rZmysql�dbzselect * from userN)�	databases�copy�pymysql�connectr
r�close)r�kwargsrrrrr�test_issue_6@s

zTestOldIssues.test_issue_6cCs�|jd}|j�}tj��tjd�|jd�WdQRX|jd�zC|jd|jd��|jd�|jd|jd��Wd|jd�XdS)	z1 Primary Key and Index error when selecting data rrzdrop table if exists testNaCREATE TABLE `test` (`station` int(10) NOT NULL DEFAULT '0', `dh`
datetime NOT NULL DEFAULT '2015-01-01 00:00:00', `echeance` int(1) NOT NULL
DEFAULT '0', `me` double DEFAULT NULL, `mo` double DEFAULT NULL, PRIMARY
KEY (`station`,`dh`,`echeance`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;zSELECT * FROM testz6ALTER TABLE `test` ADD INDEX `idx_station` (`station`)zdrop table test)r	r
rrr
rr)rrrrrr�test_issue_8Js



zTestOldIssues.test_issue_8cCs1ytt�Wntk
r,|j�YnXdS)z' sets DeprecationWarning in Python 2.6 N)�reloadr �DeprecationWarning�fail)rrrr�test_issue_9\s
zTestOldIssues.test_issue_9cCs�|jd}|j�}tj��tjd�|jd�WdQRXzb|jd�d}|jdd	|f�|jd
�|j�d}|jd	||k�Wd|jd�XdS)
z" can't handle large result fields rrzdrop table if exists issue13Nzcreate table issue13 (t text)�iz#insert into issue13 (t) values (%s)�xzselect t from issue13zdrop table issue13iH)r	r
rrr
rrr)rrr�size�rrrr�
test_issue_13cs




zTestOldIssues.test_issue_13cCs�|jd}|j�}tj��tjd�|jd�WdQRX|jd�z;|jdd
�|jd�|jd|j�d�Wd|jd	�XdS)z< query should be expanded before perform character encoding rrzdrop table if exists issue15Nz$create table issue15 (t varchar(32))z#insert into issue15 (t) values (%s)�äöüzselect t from issue15zdrop table issue15)r/)r	r
rrr
rrr)rrrrrr�
test_issue_15vs




zTestOldIssues.test_issue_15cCs�|jd}|j�}tj��tjd�|jd�WdQRX|jd�z;|jd�|jdd�|jd	|j�d�Wd|jd
�XdS)z% Patch for string and tuple escaping rrzdrop table if exists issue16NzFcreate table issue16 (name varchar(32) primary key, email varchar(32))z@insert into issue16 (name, email) values ('pete', 'floydophone')z'select email from issue16 where name=%s�peteZfloydophonezdrop table issue16)r1)r	r
rrr
rrr)rrrrrr�
test_issue_16�s




zTestOldIssues.test_issue_16zRtest_issue_17() requires a custom, legacy MySQL configuration and will not be run.cCs|jd}|jdd}|jdd}|j�}z�tj��tjd�|jd�WdQRX|jd�|jd�|jd	|�|j�tj	d|d
ddd
d|�}|j�}|jd�|j
d|j�d�Wd|jd�XdS)z#could not connect mysql use passwodr�hostrrzdrop table if exists issue17Nz0create table issue17 (x varchar(32) primary key)z0insert into issue17 (x) values ('hello, world!')zMgrant all privileges on %s.issue17 to 'issue17user'@'%%' identified by '1234'�userZissue17user�passwdZ1234zselect x from issue17z
hello, world!zdrop table issue17)r	rr
rrr
r�commitr r!rr)rrr3rrZconn2Zc2rrr�
test_issue_17�s"





$
zTestOldIssues.test_issue_17N)�__name__�
__module__�__qualname__rrrr$r%r)r.r0r2�	unittest2�skipr7rrrrrs
c@sseZdZdd�Zdd�Zejd�dd��Zdd	�Zd
d�Z	dd
�Z
dd�ZdS)rcCs�y*tjdddddd�|j�WnZtjk
rk}z|jd|jd�WYdd}~Xntk
r�|j�YnXdS)	Nr3�	localhost�porti�r4�rooti�r)r r!r(�OperationalErrorr�args�	Exception)r�errr�
test_issue_34�s)
zTestNewIssues.test_issue_34cCsstjdd|jd�}|j|dd�|j�}|jd�|jd�|jd|j�d�dS)	N�charset�utf8ruheißeu&create table heiße (name varchar(32))u,insert into heiße (name) values ('Pißata')uselect name from heißeuPißata)r r!r�safe_create_tabler
rrr)rrrrrr�
test_issue_33�s

zTestNewIssues.test_issue_33z&This test requires manual interventioncCs�|jd}|j�}td�y|jd�|j�Wn?tjk
r}z|jd|jd�WYdd}~XnXdS)Nrz1sudo killall -9 mysqld within the next 10 secondszselect sleep(10)i�)	r	r
�printrr(r r@rrA)rrrrCrrr�
test_issue_35�s


zTestNewIssues.test_issue_35cCsG|jd}|j�}|jd�d}x;|j�D]-}|d}|d}|dkr9|}Pq9W|j||j��|jdj|�y|jd�|j�Wntk
r�YnX|j	�|j	�z]t
jd�|jdj�}|jd�dd�|j�D�}|j||k�Wd|jd=XdS)	N�zshow processlistr�zshow tablesg�������?cSsg|]}|d�qS)rr)�.0�rowrrr�
<listcomp>�s	z/TestNewIssues.test_issue_36.<locals>.<listcomp>)
r	r
r�fetchallr�	thread_id�killr(rBr"�time�sleep�assertFalse)rrrZkill_idrN�id�infoZidsrrr�
test_issue_36�s4









zTestNewIssues.test_issue_36cCsr|jd}|j�}|jd|jd��|jd|j��|jd|jd��|jd�dS)NrrKzSELECT @foozSET @foo = 'bar'zset @foo = 'bar')N)r	r
rrr)rrrrrr�
test_issue_37�s
zTestNewIssues.test_issue_37cCs�|jd}|j�}ddd}zRtj��tjd�|jd�WdQRX|jd�|jd|f�Wd|jd	�XdS)
Nr�aii�rzdrop table if exists issue38z2create table issue38 (id integer, data mediumblob)z"insert into issue38 values (1, %s)zdrop table issue38)r	r
rrr
r)rrrZdatumrrr�
test_issue_38�s



zTestNewIssues.test_issue_38cCs�|jd}|j�}tj��tjd�|jd�WdQRXd}|djdd�tdd�D��7}zE|jd	�|jd
�|j|�|jd|j	�d�Wd|jd�XdS)
Nrrzdrop table if exists issue54zselect * from issue54 where z and css|]}d||fVqdS)z%d=%dNr)rM�irrr�	<genexpr>sz7TestNewIssues.disabled_test_issue_54.<locals>.<genexpr>i��z-create table issue54 (id integer primary key)z#insert into issue54 (id) values (7)rLzdrop table issue54)
r	r
rrr
r�join�rangerr)rrrZbig_sqlrrr�disabled_test_issue_54s


)


z$TestNewIssues.disabled_test_issue_54N)r8r9r:rDrHr;r<rJrXrYr[r`rrrrr�s		$c@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)rcCs�|jd}|j�}|jd|j��zotj��tjd�|jd�WdQRX|jd�|jd�|jd�|jd|j��Wd|jd�XdS)	z2 'Connection' object has no attribute 'insert_id' rrzdrop table if exists issue66NzGcreate table issue66 (id integer primary key auto_increment, x integer)z"insert into issue66 (x) values (1)�zdrop table issue66)r	r
r�	insert_idrrr
r)rrrrrr�
test_issue_66s





zTestGitHubIssues.test_issue_66cCs"|jd}|jtjj�}tj��,tjd�|jd�|jd�WdQRX|jd�|jd�d}d}z}|jd|�|jd|�|jd
�|j	�d}|j
|dd�|j
|dd	�|j
|dd
�Wd|jd�|jd�XdS)zI Duplicate field overwrites the previous one in the result of DictCursor rrzdrop table if exists azdrop table if exists bNz"CREATE TABLE a (id int, value int)z"CREATE TABLE b (id int, value int)rK��zinsert into a values (%s, %s)zinsert into b values (%s, %s)z+SELECT * FROM a inner join b on a.id = b.idrV�valuezb.valuezdrop table azdrop table b)rKrd)rKre)r	r
r r�
DictCursorrrr
rrPr)rrrrZ�br-rrr�
test_issue_79's(







zTestGitHubIssues.test_issue_79cCs�|jd}|j�}tj��tjd�|jd�WdQRX|jd�z8|jd�|jd�|j|j�dd�Wdtj��tjd�|jd�WdQRXXdS)	z6 Leftover trailing OK packet for "CALL my_sp" queries rrzDROP PROCEDURE IF EXISTS `foo`NzICREATE PROCEDURE `foo` ()
        BEGIN
            SELECT 1;
        ENDz
CALL foo()zSELECT 1rK)r	r
rrr
rrr)rrrrrr�
test_issue_95Bs






zTestGitHubIssues.test_issue_95cCs:tjdd|jd�}|jd�|j�}|jd�|j|j�d�|j�|j	�|jd�|j|j�d�|j�tjdd|jd�}|j�}|jd�|j|j�d�|j�|j	�|jd�|jd�|j
|j�d�|j�dS)z6 autocommit is not set after reconnecting with ping() rErFrFzselect @@autocommit;TN)r r!r�
autocommitr
rrUrr"�pingr)rrrrrr�test_issue_114Vs(










zTestGitHubIssues.test_issue_114cCs�|jd}|j�}x�dD]�}djdd�t|�D��}dj|�}z9|j|�|jd�t|j�|ks�t�Wd	t	j
��t	jd
�|jd�Wd	QRXXq Wd	S)
z> The number of fields returned by server is read in wrong way r���,z, css|]}dj|�VqdS)zc{0} integerN)�format)rMr\rrrr]tsz2TestGitHubIssues.test_issue_175.<locals>.<genexpr>z#create table test_field_count ({0})zselect * from test_field_countNrz%drop table if exists test_field_count)rnro)r	r
r^r_rpr�len�description�AssertionErrorrrr
)rrr�length�columns�sqlrrr�test_issue_175os

"



zTestGitHubIssues.test_issue_175cCsEtjdd|jd�}|j|dd�d}d}d}dd
gdgd
gdd
ggdd
ig}|j�}|j|j||d�d�|j|j||d�d�|j|j||d�d�|j|j|dd
g�d�|j|j�d�|j|j�d�|j|j�d�dS)z" Test iterable as query argument. rErFrZissue321z>create table issue321 (value_1 varchar(1), value_2 varchar(1))z7insert into issue321 (value_1, value_2) values (%s, %s)zIinsert into issue321 (value_1, value_2) values (%(value_1)s, %(value_2)s)z9select * from issue321 where value_1 in %s and value_2=%srZ�аrhZvalue_1rZvalue_2rKra�N)rZ)rZrhr)rZrx)rhrx)rrx)r r!rrGr
rrr)rrZ
sql_insertZsql_dict_insertZ
sql_select�datarrrr�test_issue_321s&	   zTestGitHubIssues.test_issue_321cCs!tjdd|jd�}|j|dd�d}d}tjd�dg}|j�}|j|d	|�|jd
�|j|j�t	|��|j|d	|�|j
|d	|||f�|jd
�x*|j�D]}|j|t	|��q�W|j
|d	|||f�dS)z5 Test mixed unicode/binary arguments in executemany. rErFrZissue364z`create table issue364 (value_1 binary(3), value_2 varchar(3)) engine=InnoDB default charset=utf8z7insert into issue364 (value_1, value_2) values (%s, %s)s�uäöürAzselect * from issue364N)r r!rrG�Binaryr
rrr�tuple�executemanyrP)rrrvZusql�valuesrrNrrr�test_issue_364�s"

zTestGitHubIssues.test_issue_364cCs�tjdd|jd�}|j|dd�|j�}d}|j|d�r�|jtjj��}|j	|�Wd	QRXn
|j	|�d
}|j|d�r�|jtjj��}|j	|�Wd	QRXn
|j	|�|j
�}|j|d�d}|j|d�rF|jtjj��}|j	|�Wd	QRXn
|j	|�|j
�}|j|d�|j	d�|j
�}|jt
|dt��d	S)z Test binary / geometry types. rErFrZissue363z�CREATE TABLE issue363 ( id INTEGER PRIMARY KEY, geom LINESTRING NOT NULL, SPATIAL KEY geom (geom)) ENGINE=MyISAM default charset=utf8zYINSERT INTO issue363 (id, geom) VALUES(1998, GeomFromText('LINESTRING(1.1 1.1,2.2 2.2)'))�rLNz!SELECT AsText(geom) FROM issue363�LINESTRING(1.1 1.1,2.2 2.2)z#SELECT AsBinary(geom) FROM issue363�)�������?�������?������@������@zSELECT geom FROM issue363)r�rLr)r�rLr)r�)r�rLr)r�)r r!rrGr
Zmysql_server_isZassertWarns�err�Warningrrrrr�bytes)rrr�query�cmrNrrr�test_issue_363�s8


	
zTestGitHubIssues.test_issue_363cCs5tjdd|jd�}tj��tjd�tjddtj�x�tjtj	fD]�}|j
|�}z�y|jd�|j�Wnutjk
r	}zR|j
t|j�d�|j
|jdd	�|jt|jd
t��WYdd}~XnX|jd�Wd|j�Xq_WWdQRXdS)
z Test warning propagation rErFrr�error�categoryzSELECT CAST('124b' AS SIGNED)rairKNzShould raise Warning)r r!rrr�simplefilterr�r�Cursor�SSCursorr
rrPrrqrArrrr(r")rrZcursor_classrrCrrr�test_issue_491�s


0zTestGitHubIssues.test_issue_491N)r8r9r:rcrirjrmrwr{r�r�r�rrrrrs4)rrSr�sysr rZpymysql._compatrZ
pymysql.testsrr;�impr&�AttributeError�__all__ZPyMySQLTestCaserrrrrrr�<module>s"

�i