1111# limitations under the License.
1212from __future__ import absolute_import , division , print_function
1313from datetime import datetime
14- import uuid
1514import math
1615
17- import fixtures
18- from fixtures import run_trino
16+ from conftest import TRINO_VERSION
1917import pytest
2018import pytz
2119
@@ -53,7 +51,7 @@ def test_select_query(trino_connection):
5351 rows = cur .fetchall ()
5452 assert len (rows ) > 0
5553 row = rows [0 ]
56- assert row [2 ] == fixtures . TRINO_VERSION
54+ assert row [2 ] == TRINO_VERSION
5755 columns = dict ([desc [:2 ] for desc in cur .description ])
5856 assert columns ["node_id" ] == "varchar"
5957 assert columns ["http_uri" ] == "varchar"
@@ -97,7 +95,7 @@ def test_none_query_param(trino_connection):
9795 cur .execute ("SELECT ?" , params = (None ,))
9896 rows = cur .fetchall ()
9997
100- assert rows [0 ][0 ] == None
98+ assert rows [0 ][0 ] is None
10199
102100
103101def test_string_query_param (trino_connection ):
@@ -112,18 +110,13 @@ def test_string_query_param(trino_connection):
112110def test_datetime_query_param (trino_connection ):
113111 cur = trino_connection .cursor ()
114112
115- cur .execute (
116- "SELECT ?" ,
117- params = (datetime (2020 , 1 , 1 , 0 , 0 , 0 ),)
118- )
113+ cur .execute ("SELECT ?" , params = (datetime (2020 , 1 , 1 , 0 , 0 , 0 ),))
119114 rows = cur .fetchall ()
120115
121116 assert rows [0 ][0 ] == "2020-01-01 00:00:00.000"
122117
123- cur .execute (
124- "SELECT ?" ,
125- params = (datetime (2020 , 1 , 1 , 0 , 0 , 0 , tzinfo = pytz .utc ),)
126- )
118+ cur .execute ("SELECT ?" ,
119+ params = (datetime (2020 , 1 , 1 , 0 , 0 , 0 , tzinfo = pytz .utc ),))
127120 rows = cur .fetchall ()
128121
129122 assert rows [0 ][0 ] == "2020-01-01 00:00:00.000 UTC"
@@ -138,12 +131,10 @@ def test_array_query_param(trino_connection):
138131
139132 assert rows [0 ][0 ] == [1 , 2 , 3 ]
140133
141- cur .execute (
142- "SELECT ?" ,
143- params = ([[1 , 2 , 3 ],[4 ,5 ,6 ]],))
134+ cur .execute ("SELECT ?" , params = ([[1 , 2 , 3 ], [4 , 5 , 6 ]],))
144135 rows = cur .fetchall ()
145136
146- assert rows [0 ][0 ] == [[1 , 2 , 3 ],[4 ,5 , 6 ]]
137+ assert rows [0 ][0 ] == [[1 , 2 , 3 ], [4 , 5 , 6 ]]
147138
148139 cur .execute ("SELECT TYPEOF(?)" , params = ([1 , 2 , 3 ],))
149140 rows = cur .fetchall ()
@@ -171,12 +162,12 @@ def test_boolean_query_param(trino_connection):
171162 cur .execute ("SELECT ?" , params = (True ,))
172163 rows = cur .fetchall ()
173164
174- assert rows [0 ][0 ] == True
165+ assert rows [0 ][0 ] is True
175166
176167 cur .execute ("SELECT ?" , params = (False ,))
177168 rows = cur .fetchall ()
178169
179- assert rows [0 ][0 ] == False
170+ assert rows [0 ][0 ] is False
180171
181172
182173def test_float_query_param (trino_connection ):
@@ -201,6 +192,7 @@ def test_float_nan_query_param(trino_connection):
201192
202193@pytest .mark .skip (reason = "Nan currently not returning the correct python type fon inf" )
203194def test_float_inf_query_param (trino_connection ):
195+ cur = trino_connection .cursor ()
204196 cur .execute ("SELECT ?" , params = (float ("inf" ),))
205197 rows = cur .fetchall ()
206198
@@ -368,15 +360,15 @@ def test_transaction_multiple(trino_connection_with_transaction):
368360 assert len (rows1 ) == 1000
369361 assert len (rows2 ) == 1000
370362
363+
371364def test_invalid_query_throws_correct_error (trino_connection ):
372- """
373- tests that an invalid query raises the correct exception
365+ """Tests that an invalid query raises the correct exception
374366 """
375367 cur = trino_connection .cursor ()
376368 with pytest .raises (TrinoQueryError ):
377369 cur .execute (
378370 """
379- select * FRMO foo WHERE x = ?;
371+ select * FRMO foo WHERE x = ?;
380372 """ ,
381373 params = (3 ,),
382374 )
0 commit comments