Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/unit/io/test_twistedreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,23 @@ def setUp(self):
self.reactor_cft_patcher = patch(
'twisted.internet.reactor.callFromThread')
self.reactor_run_patcher = patch('twisted.internet.reactor.run')
# Patch reactor.running to False so maybe_start() always enters
# the branch that spawns the reactor thread. Without this, leaked
# reactor state from prior tests can cause reactor.running to be
# True, making maybe_start() a no-op and the reactor.run mock
# never called — leading to a flaky test_connection_initialization.
self.reactor_running_patcher = patch(
'twisted.internet.reactor.running', new=False)
self.mock_reactor_cft = self.reactor_cft_patcher.start()
self.mock_reactor_run = self.reactor_run_patcher.start()
self.reactor_running_patcher.start()
self.obj_ut = twistedreactor.TwistedConnection(DefaultEndPoint('1.2.3.4'),
cql_version='3.0.1')

def tearDown(self):
self.reactor_cft_patcher.stop()
self.reactor_run_patcher.stop()
self.reactor_running_patcher.stop()

def test_connection_initialization(self):
"""
Expand Down
Loading