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