在python flask中编写单元测试时出现问题

我正在尝试在功能上使用python3的unittest模块进行单元测试,但是我不知道应该从哪里开始。 这是功能-

@appl.route('/campaign/<id_sele>/debug/<group_inte>', methods=['GET', 'POST'])
@login_required
def campaign_debug(id_sele, group_inte):
    group_inte_int = int(group_inte)

    # Keywords associated to the campaign
    keywords_sele = Keywords.generic_search(id_sele)

    stringa = ""
    counter_ele = 0

    Fina_lista_final_pre = []
    Fina_lista_final = []

    for ele in keywords_sele:
        if not ele.accepted:
            Fina_lista_final_pre.append(str(ele.value))

    for keyword_to_analyze in Fina_lista_final_pre:
        status = True
        for bad in ['₤', '%', ',', '*']:
            if bad in keyword_to_analyze:
                status = False
        if status:
            Fina_lista_final.append(keyword_to_analyze)

    # conversione in ascii
    for ele in Fina_lista_final[(4998) * group_inte_int:(4998) * (group_inte_int + 1)]:
        stringa += str(ele) + '</p>'
        counter_ele += 1

    final = 'Numero oggetti: ' + str(counter_ele) + '///' + '</p>' + stringa + '///'

    return final

请帮我解决这个问题,因为我在这个问题上停留了4天。谢谢。

评论