@@ -219,8 +219,8 @@ def test_connectionLostWhileReading(self):
219
219
* a NOTIFY comes through and doRead is triggered
220
220
* not all data is read from the socket and it remains readable
221
221
* the connection is closed and the Deferred returned from poll()
222
- called inside doRead is errbacked without
58E8
being ever available to user
223
- code
222
+ called inside doRead is errbacked without being ever available to
223
+ user code
224
224
225
225
It has been reported that under heavy load this can happen.
226
226
"""
@@ -317,14 +317,14 @@ def test_multipleConnections(self):
317
317
host = DB_HOST , database = DB_NAME )
318
318
319
319
d .addCallback (lambda c : conn .connect (
320
- user = DB_USER , password = DB_PASS ,
321
- host = DB_HOST , database = DB_NAME ))
320
+ user = DB_USER , password = DB_PASS ,
321
+ host = DB_HOST , database = DB_NAME ))
322
322
d = self .failUnlessFailure (d , txpostgres .AlreadyConnected )
323
323
324
324
d .addCallback (lambda _ : conn .close ())
325
325
d .addCallback (lambda _ : conn .connect (
326
- user = DB_USER , password = DB_PASS ,
327
- host = DB_HOST , database = DB_NAME ))
326
+ user = DB_USER , password = DB_PASS ,
327
+ host = DB_HOST , database = DB_NAME ))
328
328
return d .addCallback (lambda c : c .close ())
329
329
330
330
def test_errors (self ):
@@ -603,11 +603,11 @@ def test_runOperation(self):
603
603
d .addCallback (self .assertEquals , [(0 , )])
604
604
605
605
d .addCallback (lambda _ : self .conn .runOperation (
606
- "insert into simple values (%s)" , (1 , )))
606
+ "insert into simple values (%s)" , (1 , )))
607
607
d .addCallback (self .assertIdentical , None )
608
608
609
609
d .addCallback (lambda _ : self .conn .runQuery (
610
- "select count(*) from simple" ))
610
+ "select count(*) from simple" ))
611
611
return d .addCallback (self .assertEquals , [(1 , )])
612
612
613
613
def test_runSimpleInteraction (self ):
@@ -629,7 +629,7 @@ def interaction(c, arg1, kwarg1):
629
629
d .addCallback (self .assertEquals , "interaction done" )
630
630
631
631
d .addCallback (lambda _ : self .conn .runQuery (
632
- "select * from simple order by x" ))
632
+ "select * from simple order by x" ))
633
633
return d .addCallback (self .assertEquals , [(1 , ), (2 , )])
634
634
635
635
def test_runErrorInteraction (self ):
@@ -646,7 +646,7 @@ def interaction(c):
646
646
d = self .assertFailure (d , psycopg2 .ProgrammingError )
647
647
648
648
d .addCallback (lambda _ : self .conn .runQuery (
649
- "select count(*) from simple" ))
649
+ "select count(*) from simple" ))
650
650
return d .addCallback (self .assertEquals , [(0 , )])
651
651
652
652
def test_errorOnRollback (self ):
@@ -708,7 +708,7 @@ def test_terminatedConnection(self):
708
708
# added correct terminated connection handling. Then only way to know
709
709
# that seems to be looking at the __version__ string.
710
710
if (getattr (psycopg2 , '_impl' , None ) and
711
- 'ctypes' not in psycopg2 .__version__ ):
711
+ 'ctypes' not in psycopg2 .__version__ ):
712
712
raise unittest .SkipTest (
713
713
"This test fails on versions of psycopg2ct 0.3 and older, "
714
714
"which have a bug in terminated connection handling" )
@@ -897,14 +897,14 @@ def test_operation(self):
897
897
d = self .pool .runOperation ("create table x (i int)" )
898
898
# give is a workout, 20 x the number of connections
899
899
d .addCallback (lambda _ : defer .gatherResults (
900
- [self .pool .runOperation ("insert into x values (%s)" , (i , ))
901
- for i in range (self .pool .min * 20 )]))
900
+ [self .pool .runOperation ("insert into x values (%s)" , (i , ))
901
+ for i in range (self .pool .min * 20 )]))
902
902
d .addCallback (lambda _ : self .pool .runQuery (
903
- "select * from x order by i" ))
903
+ "select * from x order by i" ))
904
904
d .addCallback (self .assertEquals , [(i , ) for i in
905
- range (self .pool .min * 20 )])
905
+ range (self .pool .min * 20 )])
906
906
return d .addCallback (lambda _ : self .pool .runOperation (
907
- "drop table x" ))
907
+ "drop table x" ))
908
908
909
909
def test_interaction (self ):
910
910
"""
@@ -998,7 +998,7 @@ def checkErrorAndHotswap(f):
998
998
d .addErrback (checkErrorAndHotswap )
999
999
1000
1000
d .addCallback (lambda _ : defer .gatherResults ([
1001
- pool .runQuery ("select 1" ) for _ in range (3 )]))
1001
+ pool .runQuery ("select 1" ) for __ in range (3 )]))
1002
1002
d .addCallback (self .assertEquals , [[(1 , )]] * 3 )
1003
1003
return d .addCallback (lambda _ : pool .close ())
1004
1004
@@ -1111,7 +1111,7 @@ def cancelQuery(_):
1111
1111
d = self .conn .runInteraction (interaction )
1112
1112
d = self .failUnlessFailure (d , defer .CancelledError )
1113
1113
d .addCallback (lambda _ :
10000
self .conn .runQuery (
1114
- "select * from simple" ))
1114
+ "select * from simple" ))
1115
1115
return d .addCallback (self .assertEquals , [])
1116
1116
1117
1117
def test_cancelMultipleQueries (self ):
@@ -1158,6 +1158,7 @@ def test_removeNonexistentObserver(self):
1158
1158
1159
1159
def observer1 (notify ):
1160
1160
pass
1161
+
1161
1162
def observer2 (notify ):
1162
1163
pass
1163
1164
@@ -1210,11 +1211,12 @@ def observer(notify):
1210
1211
d .addCallback (lambda _ : notifyD )
1211
1212
d .addCallback (lambda _ : self .assertEquals (len (self .notifies ), 1 ))
1212
1213
return d .addCallback (lambda _ : self .assertEquals (
1213
- self .notifies [0 ][1 ], "txpostgres_test" ))
1214
+ self .notifies [0 ][1 ], "txpostgres_test" ))
1214
1215
1215
1216
def test_simpleNotifySameConnection (self ):
1216
1217
"""
1217
- Notifications sent from the listening session are delivered to the session.
1218
+ Notifications sent from the listening session are delivered to the
1219
+ session.
1218
1220
"""
1219
1221
notifyD = defer .Deferred ()
1220
1222
@@ -1230,7 +1232,7 @@ def observer(notify):
1230
1232
d .addCallback (lambda _ : notifyD )
1231
1233
d .addCallback (lambda _ : self .assertEquals (len (self .notifies ), 1 ))
1232
1234
return d .addCallback (lambda _ : self .assertEquals (
1233
- self .notifies [0 ][1 ], "txpostgres_test" ))
1235
+ self .notifies [0 ][1 ], "txpostgres_test" ))
1234
1236
1235
1237
def test_listenUnlisten (self ):
1236
1238
"""
@@ -1249,13 +1251,13 @@ def observer(notify):
1249
1251
d .addCallback (lambda _ : notifyD )
1250
1252
d .addCallback (lambda _ : self .assertEquals (len (self .notifies ), 1 ))
1251
1253
d .addCallback (lambda _ : self .conn .runOperation (
1252
- "unlisten txpostgres_test" ))
1254
+ "unlisten txpostgres_test" ))
1253
1255
d .addCallback (lambda _ : self .sendNotify ())
1254
1256
# run a query to force the reactor to spin and flush eventual pending
1255
1257
# notifications, which there should be none since we did unlisten
1256
1258
d .addCallback (lambda _ : self .conn .runOperation ("select 1" ))
1257
1259
return d .addCallback (lambda _ : self .assertEquals (
1258
- len (self .notifies ), 1 ))
1260
+ len (self .notifies ), 1 ))
1259
1261
1260
1262
def test_multipleNotifies (self ):
1261
1263
"""
@@ -1276,7 +1278,7 @@ def observer(notify):
1276
1278
d .addCallback (lambda _ : self .sendNotify ())
1277
1279
d .addCallback (lambda _
C94A
: notifyD )
1278
1280
return d .addCallback (lambda _ : self .assertEquals (
1279
- len (self .notifies ), 3 ))
1281
+ len (self .notifies ), 3 ))
1280
1282
1281
1283
def test_notifyDeliveryOrder (self ):
1282
1284
"""
@@ -1313,7 +1315,7 @@ def observer(notify):
1313
1315
d .addCallback (lambda _ : notifyD )
1314
1316
# check that they were processed in the right order
1315
1317
return d .addCallback (lambda _ : self .assertEquals (
1316
- [n .payload for n in self .notifies ], payloads ))
1318
+ [n .payload for n in self .notifies ], payloads ))
1317
1319
1318
1320
def test_multipleObservers (self ):
1319
1321
"""
@@ -1342,7 +1344,7 @@ def observer2(notify):
1342
1344
d .addCallback (lambda _ : firstNotifyD )
1343
1345
# the order is not determined though
1344
1346
d .addCallback (lambda _ : self .assertEquals (
1345
- set (self .notifies ), set ([1 , 2 ])))
1347
+ set (self .notifies ), set ([1 , 2 ])))
1346
1348
d .addCallback (lambda _ : self .conn .removeNotifyObserver (observer2 ))
1347
1349
d .addCallback (lambda _ : self .sendNotify ())
1348
1350
d .addCallback (lambda _ : secondNotifyD )
@@ -1380,9 +1382,9 @@ def observer2(notify):
1380
1382
d .addCallback (lambda _ : self .sendNotify ())
1381
1383
d .addCallback (lambda _ : notifyD )
1382
1384
d .addCallback (lambda _ : self .assertEquals (
1383
- len (self .flushLoggedErrors (RuntimeError )), 1 ))
1385
+ len (self .flushLoggedErrors (RuntimeError )), 1 ))
1384
1386
return d .addCallback (lambda _ : self .assertEquals (
1385
- self .notifies , [1 , 1 ]))
1387
+ self .notifies , [1 , 1 ]))
1386
1388
1387
1389
def test_observerReturnsDeferred (self ):
1388
1390
"""
@@ -1424,7 +1426,7 @@ def makeObserver(observerD, notifyD):
1424
1426
d .addCallback (lambda _ : fireAllObserverDs ())
1425
1427
# both observers should now be called
1426
1428
return d .addCallback (lambda _ : self .assertEquals (
1427
- len (self .notifies ), 2 ))
1429
+ len (self .notifies ), 2 ))
1428
1430
1429
1431
def test_observerReturnsFailingDeferred (self ):
1430
1432
"""
@@ -1455,9 +1457,9 @@ def observer(notify):
1455
1457
d .addCallback (lambda _ : notifyD )
1456
1458
# both errors get logged
1457
1459
d .addCallback (lambda _ : self .assertEquals (
1458
- len (self .flushLoggedErrors (RuntimeError )), 2 ))
1460
+ len (self .flushLoggedErrors (RuntimeError )), 2 ))
1459
1461
return d .addCallback (lambda _ : self .assertEquals (
1460
- self .notifies , [1 , 1 ]))
1462
+ self .notifies , [1 , 1 ]))
1461
1463
1462
1464
def test_customNotifyCooperator (self ):
1463
1465
"""
@@ -1490,7 +1492,7 @@ def observer(notify):
1490
1492
d .addCallback (lambda _ : self .sendNotify ())
1491
1493
d .addCallback (lambda _ : cooperateD )
1492
1494
d .addCallback (lambda _ : self .assertEquals (
1493
- cooperator .result , [True ]))
1495
+ cooperator .result , [True ]))
1494
1496
return d .addCallback (lambda _ : c .close ())
1495
1497
1496
1498
0 commit comments