1717
1818from dbutils .persistent_db import NotSupportedError , PersistentDB , local
1919
20- from .mock_db import dbapi # noqa: F401
21-
2220
2321def test_version ():
2422 """Check that the module and class versions are in sync."""
@@ -28,15 +26,15 @@ def test_version():
2826
2927
3028@pytest .mark .parametrize ("threadsafety" , [None , 0 ])
31- def test_no_threadsafety (dbapi , threadsafety ): # noqa: F811
29+ def test_no_threadsafety (dbapi , threadsafety ):
3230 """Check that a database module that is not thread-safe is rejected."""
3331 dbapi .threadsafety = threadsafety
3432 with pytest .raises (NotSupportedError ):
3533 PersistentDB (dbapi )
3634
3735
3836@pytest .mark .parametrize ("closeable" , [False , True ])
39- def test_close (dbapi , closeable ): # noqa: F811
37+ def test_close (dbapi , closeable ):
4038 """Check that closing is only allowed when the connection is closeable."""
4139 persist = PersistentDB (dbapi , closeable = closeable )
4240 db = persist .connection ()
@@ -51,7 +49,7 @@ def test_close(dbapi, closeable): # noqa: F811
5149 assert db ._con .valid is False
5250
5351
54- def test_connection (dbapi ): # noqa: F811
52+ def test_connection (dbapi ):
5553 """Check that the same thread always gets the same connection."""
5654 persist = PersistentDB (dbapi )
5755 db = persist .connection ()
@@ -67,7 +65,7 @@ def test_connection(dbapi): # noqa: F811
6765 db .close ()
6866
6967
70- def test_threads (dbapi ): # noqa: F811
68+ def test_threads (dbapi ):
7169 """Check that every thread keeps its own persistent connection."""
7270 num_threads = 3
7371 persist = PersistentDB (dbapi , closeable = True )
@@ -141,7 +139,7 @@ def run_queries(idx):
141139 query_queue [i ].put (None , timeout = 1 )
142140
143141
144- def test_maxusage (dbapi ): # noqa: F811
142+ def test_maxusage (dbapi ):
145143 """Check that the connection is reset when used too often."""
146144 persist = PersistentDB (dbapi , 20 )
147145 db = persist .connection ()
@@ -159,7 +157,7 @@ def test_maxusage(dbapi): # noqa: F811
159157 assert db ._con .num_queries == j
160158
161159
162- def test_setsession (dbapi ): # noqa: F811
160+ def test_setsession (dbapi ):
163161 """Check that the session is prepared after every reopening."""
164162 persist = PersistentDB (dbapi , 3 , ('set datestyle' ,))
165163 db = persist .connection ()
@@ -179,7 +177,7 @@ def test_setsession(dbapi): # noqa: F811
179177 assert db ._con .session == ['datestyle' ]
180178
181179
182- def test_threadlocal (dbapi ): # noqa: F811
180+ def test_threadlocal (dbapi ):
183181 """Check that the class for thread-local data can be replaced."""
184182 persist = PersistentDB (dbapi )
185183 assert isinstance (persist .thread , local )
@@ -191,7 +189,7 @@ class Threadlocal:
191189 assert isinstance (persist .thread , Threadlocal )
192190
193191
194- def test_ping_check (dbapi ): # noqa: F811
192+ def test_ping_check (dbapi ):
195193 """Check that connections are pinged as configured."""
196194 con_cls = dbapi .Connection
197195 con_cls .has_ping = True
@@ -245,7 +243,7 @@ def test_ping_check(dbapi): # noqa: F811
245243 con_cls .num_pings = 0
246244
247245
248- def test_failed_transaction (dbapi ): # noqa: F811
246+ def test_failed_transaction (dbapi ):
249247 """Check that a failed transaction is reported and recovered from."""
250248 persist = PersistentDB (dbapi )
251249 db = persist .connection ()
@@ -263,7 +261,7 @@ def test_failed_transaction(dbapi): # noqa: F811
263261 cursor .execute ('select test' )
264262
265263
266- def test_context_manager (dbapi ): # noqa: F811
264+ def test_context_manager (dbapi ):
267265 """Check that connection and cursor can be used as context managers."""
268266 persist = PersistentDB (dbapi )
269267 with persist .connection () as db :
@@ -278,15 +276,15 @@ def timeout_is_not_fatal(error):
278276 return not error .args or error .args [0 ] != 3024
279277
280278
281- def test_isfatal_default (dbapi ): # noqa: F811
279+ def test_isfatal_default (dbapi ):
282280 """Check that no error check is configured by default."""
283281 persist = PersistentDB (dbapi )
284282 assert persist ._isfatal is None
285283 db = persist .connection ()
286284 assert db ._isfatal is None
287285
288286
289- def test_isfatal (dbapi ): # noqa: F811
287+ def test_isfatal (dbapi ):
290288 """Check that isfatal is passed on and can veto the failover."""
291289 persist = PersistentDB (dbapi , isfatal = timeout_is_not_fatal )
292290 assert persist ._isfatal is timeout_is_not_fatal
@@ -303,7 +301,7 @@ def test_isfatal(dbapi): # noqa: F811
303301 assert cursor .fetchone () == 'test'
304302
305303
306- def test_no_failover (dbapi ): # noqa: F811
304+ def test_no_failover (dbapi ):
307305 """Check that no_failover() suspends the failover mechanism."""
308306 persist = PersistentDB (dbapi )
309307 db = persist .connection ()
@@ -316,7 +314,7 @@ def test_no_failover(dbapi): # noqa: F811
316314 assert cursor .fetchone () == 'test'
317315
318316
319- def test_dbapi_connection (dbapi ): # noqa: F811
317+ def test_dbapi_connection (dbapi ):
320318 """Check that the underlying DB-API 2 objects are accessible."""
321319 persist = PersistentDB (dbapi )
322320 db = persist .connection ()
0 commit comments