From 1bbd756fa6cb409d06ff41e56ec2f9a06f3d9564 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 1 Dec 2017 13:00:05 -0800 Subject: [PATCH] test_transit: fix the miscaptured-loop-variable bug I always make --- src/wormhole/test/test_transit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wormhole/test/test_transit.py b/src/wormhole/test/test_transit.py index 5d057dc..fb03f38 100644 --- a/src/wormhole/test/test_transit.py +++ b/src/wormhole/test/test_transit.py @@ -20,8 +20,8 @@ from nacl.exceptions import CryptoError class Highlander(unittest.TestCase): def test_one_winner(self): cancelled = set() - contenders = [defer.Deferred(lambda d: cancelled.add(i)) - for i in range(4)] + contenders = [defer.Deferred(lambda d, i=i: cancelled.add(i)) + for i in range(5)] d = transit.there_can_be_only_one(contenders) self.assertNoResult(d) contenders[0].errback(ValueError()) @@ -30,11 +30,11 @@ class Highlander(unittest.TestCase): self.assertNoResult(d) contenders[2].callback("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): 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)] d = transit.there_can_be_only_one(contenders) self.assertNoResult(d)