第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

執(zhí)行操作時(shí)模擬 500 響應(yīng)

執(zhí)行操作時(shí)模擬 500 響應(yīng)

明月笑刀無(wú)情 2021-11-09 10:34:03
到目前為止,這是我的測(cè)試:test_500(self):    client = ClientConfiguration(token=token, url=url)    client.url = 'https://localhost:1234/v1/' + bucket    keys = None            try:        get_bucket = json.loads(str(client.get_bucket(bucket)))        result = get_bucket['result']    except Exception as e:        expected_status_code = 500        failure_message = "Expected status code %s but got status code %s" % (expected_status_code, e)        self.assertEquals(e, expected_status_code, failure_message)我需要編寫(xiě)一個(gè)500在使用'https://localhost:1234/v1/' + bucketurl時(shí)返回響應(yīng)的模擬。這可以通過(guò) unittest 來(lái)完成,如果可以,我如何或在哪里可以找到有關(guān)此的一些文檔?我瀏覽過(guò)這個(gè)網(wǎng)站、unittest 文檔和 Youtube,但找不到任何特定于我想做的事情。
查看完整描述

1 回答

?
MM們

TA貢獻(xiàn)1886條經(jīng)驗(yàn) 獲得超2個(gè)贊

我最終使用它來(lái)創(chuàng)建我的測(cè)試。


最終結(jié)果是:


@responses.activate

test_500(self):


    responses.add(responses.GET, 'https://localhost:1234/v1/' + bucket,

        json={'error': 'server error'}, status=500)


    client = ClientConfiguration(token=token, url=url)

    client.url = 'https://localhost:1234/v1/'


    keys = None        


    try:

        get_bucket = json.loads(str(client.get_bucket(bucket)))

        result = get_bucket['result']

except Exception as e:

        expected_status_code = 500

        failure_message = "Expected status code %s but got status code %s" % (expected_status_code, e)

        self.assertEquals(e, expected_status_code, failure_message)


查看完整回答
反對(duì) 回復(fù) 2021-11-09
  • 1 回答
  • 0 關(guān)注
  • 204 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)