Merge pull request #460 from meejah/458.fix-test

fix failing test
This commit is contained in:
meejah
2022-10-27 05:55:40 +02:00
committed by GitHub
3 changed files with 21 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ User-visible changes in "magic-wormhole":
## Upcoming Release
* Python 3.5 and 3.6 are past their EOL date and support is dropped (#448)
* Fix intermittant failing test (#458)
## Release 0.12.0 (04-Apr-2020)

View File

@@ -25,16 +25,27 @@ class EventualQueue(object):
return d
def _turn(self):
while self._calls:
(f, args, kwargs) = self._calls.pop(0)
self._calls, to_call = [], self._calls
for f, args, kwargs in to_call:
try:
f(*args, **kwargs)
except Exception:
log.err()
self._timer = None
d, self._flush_d = self._flush_d, None
if d:
d.callback(None)
# Since the only guidance about semantics is the comment about
# Foolscap, we make sure that any calls added by the above
# (i.e. by the calls we just ran) only run in the _next_ turn
# (as Foolscap does). Not doing this leads to some unexpected
# dependency of the tests on the precise order things are run
# in a single turn, which defeats the purpose of this
# "eventual queue".
if len(self._calls):
self._timer = self._clock.callLater(0, self._turn)
else:
d, self._flush_d = self._flush_d, None
if d:
d.callback(None)
def flush_sync(self):
# if you have control over the Clock, this will synchronously flush the

View File

@@ -501,9 +501,12 @@ class Wormholes(ServerBase, unittest.TestCase):
w2 = wormhole.create(APPID, self.relayurl, reactor)
w2.set_code("123-NOT")
yield self.assertFailure(w1.get_verifier(), WrongPasswordError)
yield self.assertFailure(w1.get_welcome(), WrongPasswordError) # late
# we have to ensure w2 receives a "bad" message from w1 before
# the w2.close() assertion below will actually fail
yield self.assertFailure(w2.get_verifier(), WrongPasswordError)
yield self.assertFailure(w1.close(), WrongPasswordError)
yield self.assertFailure(w2.close(), WrongPasswordError)