@defer.inlineCallbacks
    def test_handling_connect_error(self):
        """ If an error occurs on connect, another attempt should be made. """
        engine_manager = self.make_engine_manager()
        engine_manager.engine = mocked_engine = self.mocker.engine
        mocked_connection = self.mocker.connection
        fake_error = FakeError()
        mocked_engine.connect.side_effect=util.get_callable_with_different_side_effects([fake_error, mocked_connection])

        engine_manager.startService()
        event = yield self.events.get()
        self.assertEquals(event[0], 'failed')
        self.assertTrue(event[1].value is fake_error)

        event = yield self.events.get()
        self.assertEquals(event, ('connected', mocked_engine))

        yield util.wait(0)
        engine_manager.stopService()
        yield util.wait(0)

        self.failIf(0 > self.events.size)
        self.assertEquals(self.mocker.mock_calls, [
            mock.call.engine.connect(),
            mock.call.engine.dispose(), # The first connect fails, so the engine is disposed.
            mock.call.engine.connect(),
            mock.call.connection(),
            mock.call.connection().execute("SELECT 'ping'"),
            mock.call.connection().close(),
            mock.call.engine.dispose() # and disposed when the service stops.
        ])
dataset/ETHPy150Open foundit/Piped/contrib/database/piped_database/test/test_database.py/EngineProviderTest.test_handling_connect_error/swapped operands of `>`