test_transit: fix the miscaptured-loop-variable bug I always make
This commit is contained in:
parent
8a7c6faf4a
commit
1bbd756fa6
|
@ -20,8 +20,8 @@ from nacl.exceptions import CryptoError
|
||||||
class Highlander(unittest.TestCase):
|
class Highlander(unittest.TestCase):
|
||||||
def test_one_winner(self):
|
def test_one_winner(self):
|
||||||
cancelled = set()
|
cancelled = set()
|
||||||
contenders = [defer.Deferred(lambda d: cancelled.add(i))
|
contenders = [defer.Deferred(lambda d, i=i: cancelled.add(i))
|
||||||
for i in range(4)]
|
for i in range(5)]
|
||||||
d = transit.there_can_be_only_one(contenders)
|
d = transit.there_can_be_only_one(contenders)
|
||||||
self.assertNoResult(d)
|
self.assertNoResult(d)
|
||||||
contenders[0].errback(ValueError())
|
contenders[0].errback(ValueError())
|
||||||
|
@ -30,11 +30,11 @@ class Highlander(unittest.TestCase):
|
||||||
self.assertNoResult(d)
|
self.assertNoResult(d)
|
||||||
contenders[2].callback("yay")
|
contenders[2].callback("yay")
|
||||||
self.assertEqual(self.successResultOf(d), "yay")
|
self.assertEqual(self.successResultOf(d), "yay")
|
||||||
self.assertEqual(cancelled, set([3]))
|
self.assertEqual(cancelled, set([3,4]))
|
||||||
|
|
||||||
def test_there_might_also_be_none(self):
|
def test_there_might_also_be_none(self):
|
||||||
cancelled = set()
|
cancelled = set()
|
||||||
contenders = [defer.Deferred(lambda d: cancelled.add(i))
|
contenders = [defer.Deferred(lambda d, i=i: cancelled.add(i))
|
||||||
for i in range(4)]
|
for i in range(4)]
|
||||||
d = transit.there_can_be_only_one(contenders)
|
d = transit.there_can_be_only_one(contenders)
|
||||||
self.assertNoResult(d)
|
self.assertNoResult(d)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user