httprunner內建斷言

2021-09-24 05:24:50 字數 1560 閱讀 6998

原始碼

def get_uniform_comparator(comparator):

""" convert comparator alias to uniform name

"""if comparator in ["eq", "equals", "==", "is"]: ##等於

return "equals"

elif comparator in ["lt", "less_than"]: ##小於

return "less_than"

elif comparator in ["le", "less_than_or_equals"]: ##小於等於

return "less_than_or_equals"

elif comparator in ["gt", "greater_than"]: ##大於

return "greater_than"

elif comparator in ["ge", "greater_than_or_equals"]: ##大於等於

return "greater_than_or_equals"

elif comparator in ["ne", "not_equals"]: ##不等於

return "not_equals"

elif comparator in ["str_eq", "string_equals"]: ##字串相等

return "string_equals"

elif comparator in ["len_eq", "length_equals", "count_eq"]: ##長度相等

return "length_equals"

elif comparator in ["len_gt", "count_gt", "length_greater_than", "count_greater_than"]: ##長度大於

return "length_greater_than"

elif comparator in ["len_ge", "count_ge", "length_greater_than_or_equals", \ ##長度大於等於

"count_greater_than_or_equals"]:

return "length_greater_than_or_equals"

elif comparator in ["len_lt", "count_lt", "length_less_than", "count_less_than"]: ##長度小於

return "length_less_than"

elif comparator in ["len_le", "count_le", "length_less_than_or_equals", \ ##長度小於等於

"count_less_than_or_equals"]:

return "length_less_than_or_equals"

else:

return comparator ##自定義

簡單執行httprunner

先簡單的弄個demo,執行起來看看 一 錄製 fiddler中介面匯出 file export sessions selected sessions select export format 勾選httparchive v1.1 勾選httparchive v1.1型別後,下一步匯出為 檔名.har...

Httprunner初步學習

一 簡介 一直在技術部落格上看到httprunner測試框架,但始終不太明白這個框架的具體作用,今天就花點時間來初步學習了解一下。httprunner 是一款面向 http s 協議的通用測試框架,只需編寫維護乙份yaml json指令碼,即可實現自動化測試 效能測試 線上監控 持續整合等多種測試需...

httprunner呼叫api模板

建立登入api模板,使用者名稱密碼預設800001,狀態響應碼預設200 name 登入介面模板 variables expected status code 200 password 800001 username 800001 vercode request url api login json...