mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-14 11:17:35 +08:00
change: remove unused imports
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
@@ -8,12 +7,15 @@ from tests.api_server import HTTPBIN_SERVER, gen_md5, get_sign
|
||||
|
||||
BASE_URL = "http://127.0.0.1:5000"
|
||||
|
||||
|
||||
def get_httpbin_server():
|
||||
return HTTPBIN_SERVER
|
||||
|
||||
|
||||
def get_base_url():
|
||||
return BASE_URL
|
||||
|
||||
|
||||
def get_default_request():
|
||||
return {
|
||||
"base_url": BASE_URL,
|
||||
@@ -22,9 +24,11 @@ def get_default_request():
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def sum_two(m, n):
|
||||
return m + n
|
||||
|
||||
|
||||
def sum_status_code(status_code, expect_sum):
|
||||
""" sum status code digits
|
||||
e.g. 400 => 4, 201 => 3
|
||||
@@ -35,34 +39,42 @@ def sum_status_code(status_code, expect_sum):
|
||||
|
||||
assert sum_value == expect_sum
|
||||
|
||||
|
||||
def is_status_code_200(status_code):
|
||||
return status_code == 200
|
||||
|
||||
|
||||
os.environ["TEST_ENV"] = "PRODUCTION"
|
||||
|
||||
|
||||
def skip_test_in_production_env():
|
||||
""" skip this test in production environment
|
||||
"""
|
||||
return os.environ["TEST_ENV"] == "PRODUCTION"
|
||||
|
||||
|
||||
def get_user_agent():
|
||||
return ["iOS/10.1", "iOS/10.2"]
|
||||
|
||||
|
||||
def gen_app_version():
|
||||
return [
|
||||
{"app_version": "2.8.5"},
|
||||
{"app_version": "2.8.6"}
|
||||
]
|
||||
|
||||
|
||||
def get_account():
|
||||
return [
|
||||
{"username": "user1", "password": "111111"},
|
||||
{"username": "user2", "password": "222222"}
|
||||
]
|
||||
|
||||
|
||||
def get_account_in_tuple():
|
||||
return [("user1", "111111"), ("user2", "222222")]
|
||||
|
||||
|
||||
def gen_random_string(str_len):
|
||||
random_char_list = []
|
||||
for _ in range(str_len):
|
||||
@@ -72,12 +84,15 @@ def gen_random_string(str_len):
|
||||
random_string = ''.join(random_char_list)
|
||||
return random_string
|
||||
|
||||
|
||||
def setup_hook_add_kwargs(request):
|
||||
request["key"] = "value"
|
||||
|
||||
|
||||
def setup_hook_remove_kwargs(request):
|
||||
request.pop("key")
|
||||
|
||||
|
||||
def teardown_hook_sleep_N_secs(response, n_secs):
|
||||
""" sleep n seconds after request
|
||||
"""
|
||||
@@ -86,12 +101,15 @@ def teardown_hook_sleep_N_secs(response, n_secs):
|
||||
else:
|
||||
time.sleep(n_secs)
|
||||
|
||||
|
||||
def hook_print(msg):
|
||||
print(msg)
|
||||
|
||||
|
||||
def modify_request_json(request, os_platform):
|
||||
request["json"]["os_platform"] = os_platform
|
||||
|
||||
|
||||
def setup_hook_httpntlmauth(request):
|
||||
if "httpntlmauth" in request:
|
||||
from requests_ntlm import HttpNtlmAuth
|
||||
@@ -99,6 +117,7 @@ def setup_hook_httpntlmauth(request):
|
||||
request["auth"] = HttpNtlmAuth(
|
||||
auth_account["username"], auth_account["password"])
|
||||
|
||||
|
||||
def alter_response(response):
|
||||
response.status_code = 500
|
||||
response.headers["Content-Type"] = "html/text"
|
||||
@@ -108,6 +127,7 @@ def alter_response(response):
|
||||
"key": 123
|
||||
}
|
||||
|
||||
|
||||
def alter_response_error(response):
|
||||
# NameError
|
||||
not_defined_variable
|
||||
|
||||
Reference in New Issue
Block a user