mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-19 07:48:11 +00:00
refactor for Windows testing
This commit is contained in:
@ -241,12 +241,12 @@ def on_stdin_close(reactor, fn):
|
||||
|
||||
when_closed_d.addBoth(on_close)
|
||||
# we don't need to do anything with this instance because it gets
|
||||
# hooked into the reactor and thus remembered
|
||||
StandardIO(
|
||||
# hooked into the reactor and thus remembered .. but we return it
|
||||
# for Windows testing purposes.
|
||||
return StandardIO(
|
||||
proto=WhenClosed(),
|
||||
reactor=reactor,
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
def run(config, runApp=twistd.runApp):
|
||||
|
@ -643,15 +643,18 @@ class OnStdinCloseTests(SyncTestCase):
|
||||
|
||||
def onclose():
|
||||
called.append(True)
|
||||
on_stdin_close(reactor, onclose)
|
||||
proto = on_stdin_close(reactor, onclose)
|
||||
self.assertEqual(called, [])
|
||||
|
||||
print("READERS", reactor.getReaders())
|
||||
|
||||
for reader in reactor.getReaders():
|
||||
reader.loseConnection()
|
||||
reader.loseConnection()
|
||||
reactor.advance(1) # ProcessReader does a callLater(0, ..)
|
||||
# one Unix we can just close all the readers, correctly
|
||||
# "simulating" a stdin close .. of course, Windows has to be
|
||||
# difficult
|
||||
if platform.isWindows():
|
||||
proto.loseConnection()
|
||||
else:
|
||||
for reader in reactor.getReaders():
|
||||
reader.loseConnection()
|
||||
reactor.advance(1) # ProcessReader does a callLater(0, ..)
|
||||
|
||||
self.assertEqual(called, [True])
|
||||
|
||||
@ -668,9 +671,11 @@ class OnStdinCloseTests(SyncTestCase):
|
||||
on_stdin_close(reactor, onclose)
|
||||
self.assertEqual(called, [])
|
||||
|
||||
for reader in reactor.getReaders():
|
||||
reader.loseConnection()
|
||||
reader.loseConnection()
|
||||
reactor.advance(1) # ProcessReader does a callLater(0, ..)
|
||||
if platform.isWindows():
|
||||
proto.loseConnection()
|
||||
else:
|
||||
for reader in reactor.getReaders():
|
||||
reader.loseConnection()
|
||||
reactor.advance(1) # ProcessReader does a callLater(0, ..)
|
||||
|
||||
self.assertEqual(called, [True])
|
||||
|
Reference in New Issue
Block a user