Skip to content

Commit b5cf6b3

Browse files
committed
test_twistedreactor: Fix failing test_connection_initialization
This test verifies that the run method of the loop was called during setUp, but another test (`class TestTwistedTimer`) was creating and starting the loop before - and this loop was never stopped. This commit adds cleanup procedure so that the test works even if loop was started before.
1 parent a2a3761 commit b5cf6b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/unit/io/test_twistedreactor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class TestTwistedConnection(unittest.TestCase):
9191
def setUp(self):
9292
if twistedreactor is None:
9393
raise unittest.SkipTest("Twisted libraries not available")
94+
twistedreactor.TwistedConnection._loop._cleanup()
9495
twistedreactor.TwistedConnection.initialize_reactor()
9596
self.reactor_cft_patcher = patch(
9697
'twisted.internet.reactor.callFromThread')
@@ -109,7 +110,6 @@ def test_connection_initialization(self):
109110
Verify that __init__() works correctly.
110111
"""
111112
self.mock_reactor_cft.assert_called_with(self.obj_ut.add_connection)
112-
self.obj_ut._loop._cleanup()
113113
self.mock_reactor_run.assert_called_with(installSignalHandlers=False)
114114

115115
def test_client_connection_made(self):

0 commit comments

Comments
 (0)