@@ -29,9 +29,11 @@ def _test_isolation_level_read_only(
2929 cursor = connection .cursor ()
3030 with suppress (dbapi .DatabaseError ):
3131 maybe_await (cursor .execute_scheme ("DROP TABLE foo" ))
32- maybe_await (cursor .execute_scheme (
33- "CREATE TABLE foo(id Int64 NOT NULL, PRIMARY KEY (id))"
34- ))
32+ maybe_await (
33+ cursor .execute_scheme (
34+ "CREATE TABLE foo(id Int64 NOT NULL, PRIMARY KEY (id))"
35+ )
36+ )
3537
3638 connection .set_isolation_level (isolation_level )
3739 cursor = connection .cursor ()
@@ -60,9 +62,11 @@ def _test_connection(self, connection: dbapi.Connection) -> None:
6062 with pytest .raises (dbapi .ProgrammingError ):
6163 maybe_await (connection .describe ("/local/foo" ))
6264
63- maybe_await (cur .execute_scheme (
64- "CREATE TABLE foo(id Int64 NOT NULL, PRIMARY KEY (id))"
65- ))
65+ maybe_await (
66+ cur .execute_scheme (
67+ "CREATE TABLE foo(id Int64 NOT NULL, PRIMARY KEY (id))"
68+ )
69+ )
6670
6771 assert maybe_await (connection .check_exists ("/local/foo" ))
6872
@@ -84,26 +88,28 @@ def _test_cursor_raw_query(self, connection: dbapi.Connection) -> None:
8488 "CREATE TABLE test(id Int64 NOT NULL, text Utf8, PRIMARY KEY (id))"
8589 ))
8690
87- maybe_await (cur .execute (
88- """
91+ maybe_await (
92+ cur .execute (
93+ """
8994 DECLARE $data AS List<Struct<id:Int64, text: Utf8>>;
9095
9196 INSERT INTO test SELECT id, text FROM AS_TABLE($data);
9297 """ ,
93- {
94- "$data" : ydb .TypedValue (
95- [
96- {"id" : 17 , "text" : "seventeen" },
97- {"id" : 21 , "text" : "twenty one" },
98- ],
99- ydb .ListType (
100- ydb .StructType ()
101- .add_member ("id" , ydb .PrimitiveType .Int64 )
102- .add_member ("text" , ydb .PrimitiveType .Utf8 )
103- ),
104- )
105- },
106- ))
98+ {
99+ "$data" : ydb .TypedValue (
100+ [
101+ {"id" : 17 , "text" : "seventeen" },
102+ {"id" : 21 , "text" : "twenty one" },
103+ ],
104+ ydb .ListType (
105+ ydb .StructType ()
106+ .add_member ("id" , ydb .PrimitiveType .Int64 )
107+ .add_member ("text" , ydb .PrimitiveType .Utf8 )
108+ ),
109+ )
110+ },
111+ )
112+ )
107113
108114 maybe_await (cur .execute_scheme ("DROP TABLE test" ))
109115
@@ -112,13 +118,15 @@ def _test_cursor_raw_query(self, connection: dbapi.Connection) -> None:
112118 def _test_errors (
113119 self ,
114120 connection : dbapi .Connection ,
115- connect_method : callable = dbapi .connect
121+ connect_method : callable = dbapi .connect ,
116122 ) -> None :
117123 with pytest .raises (dbapi .InterfaceError ):
118- maybe_await (connect_method (
119- "localhost:2136" , # type: ignore
120- database = "/local666" , # type: ignore
121- ))
124+ maybe_await (
125+ connect_method (
126+ "localhost:2136" , # type: ignore
127+ database = "/local666" , # type: ignore
128+ )
129+ )
122130
123131 cur = connection .cursor ()
124132
@@ -137,9 +145,9 @@ def _test_errors(
137145 with pytest .raises (dbapi .ProgrammingError ):
138146 maybe_await (cur .execute ("SELECT * FROM test" ))
139147
140- maybe_await (cur . execute_scheme (
141- "CREATE TABLE test(id Int64, PRIMARY KEY (id))"
142- ))
148+ maybe_await (
149+ cur . execute_scheme ( "CREATE TABLE test(id Int64, PRIMARY KEY (id))" )
150+ )
143151
144152 maybe_await (cur .execute ("INSERT INTO test(id) VALUES(1)" ))
145153
@@ -154,8 +162,9 @@ def _test_bulk_upsert(self, connection: dbapi.Connection) -> None:
154162 with suppress (dbapi .DatabaseError ):
155163 maybe_await (cursor .execute_scheme ("DROP TABLE pet" ))
156164
157- maybe_await (cursor .execute_scheme (
158- """
165+ maybe_await (
166+ cursor .execute_scheme (
167+ """
159168 CREATE TABLE pet (
160169 pet_id INT,
161170 name TEXT NOT NULL,
@@ -165,7 +174,8 @@ def _test_bulk_upsert(self, connection: dbapi.Connection) -> None:
165174 PRIMARY KEY (pet_id)
166175 );
167176 """
168- ))
177+ )
178+ )
169179
170180 column_types = (
171181 ydb .BulkUpsertColumns ()
@@ -182,14 +192,14 @@ def _test_bulk_upsert(self, connection: dbapi.Connection) -> None:
182192 "name" : "Lester" ,
183193 "pet_type" : "Hamster" ,
184194 "birth_date" : "2020-06-23" ,
185- "owner" : "Lily"
195+ "owner" : "Lily" ,
186196 },
187197 {
188198 "pet_id" : 4 ,
189199 "name" : "Quincy" ,
190200 "pet_type" : "Parrot" ,
191201 "birth_date" : "2013-08-11" ,
192- "owner" : "Anne"
202+ "owner" : "Anne" ,
193203 },
194204 ]
195205
@@ -204,18 +214,19 @@ def _test_error_with_interactive_tx(
204214 self ,
205215 connection : dbapi .Connection ,
206216 ) -> None :
207-
208217 cur = connection .cursor ()
209- maybe_await (cur .execute_scheme (
210- """
218+ maybe_await (
219+ cur .execute_scheme (
220+ """
211221 DROP TABLE IF EXISTS test;
212222 CREATE TABLE test (
213223 id Int64 NOT NULL,
214224 val Int64,
215225 PRIMARY KEY(id)
216226 )
217227 """
218- ))
228+ )
229+ )
219230
220231 connection .set_isolation_level (dbapi .IsolationLevel .SERIALIZABLE )
221232 maybe_await (connection .begin ())
@@ -274,8 +285,8 @@ def test_bulk_upsert(self, connection: dbapi.Connection) -> None:
274285 self ._test_bulk_upsert (connection )
275286
276287 def test_errors_with_interactive_tx (
277- self , connection : dbapi .Connection
278- ) -> None :
288+ self , connection : dbapi .Connection
289+ ) -> None :
279290 self ._test_error_with_interactive_tx (connection )
280291
281292
@@ -291,8 +302,10 @@ def connect() -> dbapi.AsyncConnection:
291302 try :
292303 yield conn
293304 finally :
305+
294306 def close () -> None :
295307 maybe_await (conn .close ())
308+
296309 await greenlet_spawn (close )
297310
298311 @pytest .mark .asyncio
@@ -315,7 +328,9 @@ async def test_isolation_level_read_only(
315328 ) -> None :
316329 await greenlet_spawn (
317330 self ._test_isolation_level_read_only ,
318- connection , isolation_level , read_only
331+ connection ,
332+ isolation_level ,
333+ read_only ,
319334 )
320335
321336 @pytest .mark .asyncio
0 commit comments