8000 Change cancellation tests to use smaller values for pg_sleep. · wulczer/txpostgres@5da7762 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5da7762

Browse files
committed
Change cancellation tests to use smaller values for pg_sleep.
If the cancellation does not work, it's better to have a failed test after a few seconds than a stuck test that requires terminating the entire trial run.
1 parent 1231366 commit 5da7762

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/test_txpostgres.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,12 @@ def setUp(self):
788788
return _SimpleDBSetupMixin.setUp(self)
789789

790790
def test_simpleCancellation(self):
791-
d = self.conn.runQuery("select pg_sleep(1000)")
791+
d = self.conn.runQuery("select pg_sleep(5)")
792792
reactor.callLater(0, self.conn.cancel, d)
793793
return self.failUnlessFailure(d, defer.CancelledError)
794794

795795
def test_directCancellation(self):
796-
d = self.conn.runQuery("select pg_sleep(1000)")
796+
d = self.conn.runQuery("select pg_sleep(5)")
797797

798798
def tryDirectCancel(d):
799799
self.assertRaises(txpostgres._CancelInProgress, d.cancel)
@@ -810,7 +810,7 @@ def cancelAndPassthrough(ret):
810810
d = c.execute("insert into simple values (1)")
811811
d.addCallback(lambda c: c.execute("insert into simple values (2)"))
812812
d.addCallback(cancelAndPassthrough)
813-
d.addCallback(lambda c: c.execute("select pg_sleep(1000)"))
813+
d.addCallback(lambda c: c.execute("select pg_sleep(5)"))
814814
return d.addCallback(lambda _: "interaction done")
815815

816816
d = self.conn.runInteraction(interaction)
@@ -820,8 +820,8 @@ def cancelAndPassthrough(ret):
820820
return d.addCallback(self.assertEquals, [])
821821

822822
def test_cancelMultipleQueries(self):
823-
d1 = self.conn.runQuery("select pg_sleep(1000)")
824-
d2 = self.conn.runQuery("select pg_sleep(1000)")
823+
d1 = self.conn.runQuery("select pg_sleep(5)")
824+
d2 = self.conn.runQuery("select pg_sleep(5)")
825825
reactor.callLater(0, self.conn.cancel, d1)
826826
reactor.callLater(0, self.conn.cancel, d2)
827827

0 commit comments

Comments
 (0)
0