'Test for asserting that watchers are closed in LibevConnection
This test simulates a process termination without calling cluster.shutdown(), which would trigger
LibevConnection._libevloop._cleanup. It will check the watchers have been closed
Finally it will restore the LibevConnection reactor so it doesn\'t affect
the rest of the tests
@since 3.10
@jira_ticket PYTHON-747
@expected_result the watchers are closed
@test_category connection'

def test_watchers_are_finished(self, *args):

    with patch.object(LibevConnection._libevloop, '_thread'):
        with patch.object(LibevConnection._libevloop, 'notify'):
            self.make_connection()
            live_connections = set(LibevConnection._libevloop._live_conns)
            libev__cleanup(weakref.ref(LibevConnection._libevloop))
            for conn in live_connections:
                for watcher in (conn._write_watcher, conn._read_watcher):
                    self.assertTrue(watcher.stop.mock_calls)
    LibevConnection._libevloop._shutdown = False
