def test_clear_not_existing_connection(): """ Test clearing connection from the local thread which was never set. """ repl = Repl() repl.clear_connection() assert repl.get_connection() is None assert repl.is_repl_active is False
def test_clear_connection(): """ Test clearing connection from the local thread. """ repl = Repl() connection = TestConnection() repl.set_connection(connection) repl.clear_connection() assert repl.get_connection() is None assert repl.is_repl_active is False
def test_clear_not_existing_thread_data(mock_threading): """ Test clearing the thread data. """ local_thread_data = Mock() delattr(local_thread_data, REPL_CONNECTION_ATTRIBUTE) mock_threading.local.return_value = local_thread_data repl = Repl() repl.clear_connection() connection = repl.get_connection() assert connection is None assert repl.is_repl_active is False