change: remove unused imports

This commit is contained in:
debugtalk
2019-10-04 23:12:20 +08:00
parent 8a9407073f
commit ff75c13543
18 changed files with 43 additions and 26 deletions

View File

@@ -1,6 +1,5 @@
# encoding: utf-8
import os
import unittest
from httprunner import (__version__, exceptions, loader, logger, parser,

View File

@@ -5,7 +5,6 @@ Built-in dependent functions used in YAML/JSON testcases.
"""
import datetime
import json
import os
import random
import re
@@ -13,10 +12,11 @@ import string
import time
import filetype
from httprunner.compat import basestring, builtin_str, integer_types, str
from httprunner.exceptions import ParamsError
from requests_toolbelt import MultipartEncoder
from httprunner.compat import basestring, builtin_str, integer_types
from httprunner.exceptions import ParamsError
PWD = os.getcwd()

View File

@@ -4,12 +4,13 @@ import time
import requests
import urllib3
from httprunner import logger
from httprunner.utils import lower_dict_keys, omit_long_data
from requests import Request, Response
from requests.exceptions import (InvalidSchema, InvalidURL, MissingSchema,
RequestException)
from httprunner import logger
from httprunner.utils import lower_dict_keys, omit_long_data
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

View File

@@ -1,5 +1,3 @@
import collections
import copy
import csv
import importlib
import io
@@ -8,7 +6,8 @@ import os
import sys
import yaml
from httprunner import built_in, exceptions, logger, parser, utils, validator
from httprunner import built_in, exceptions, logger, utils, validator
try:
# PyYAML version >= 5.1

View File

@@ -6,7 +6,6 @@ import os
import sys
from httprunner.logger import color_print
from httprunner import loader
def parse_locustfile(file_path):

View File

@@ -10,10 +10,11 @@ from collections import Iterable
from datetime import datetime
import requests
from httprunner import __version__, loader, logger
from httprunner.compat import basestring, bytes, json, numeric_types
from jinja2 import Template, escape
from httprunner import __version__, logger
from httprunner.compat import basestring, bytes, json, numeric_types
def get_platform():
return {

View File

@@ -1,13 +1,12 @@
# encoding: utf-8
import json
import re
import jsonpath
from httprunner import exceptions, logger, utils
from httprunner.compat import OrderedDict, basestring, is_py2
text_extractor_regexp_compile = re.compile(r".*\(.*\).*")

View File

@@ -7,7 +7,6 @@ import itertools
import json
import os.path
import re
import string
from datetime import datetime
from httprunner import exceptions, logger

View File

@@ -7,11 +7,11 @@ import types
from httprunner import exceptions, logger
""" validate data format
TODO: refactor with JSON schema validate
"""
def is_testcase(data_structure):
""" check if data_structure is a testcase.

View File

@@ -4,6 +4,7 @@ import json
from functools import wraps
from flask import Flask, make_response, request
from httprunner.built_in import gen_random_string
try:
@@ -53,6 +54,7 @@ def get_sign(*args):
sign = hmac.new(sign_key, content, hashlib.sha1).hexdigest()
return sign
def gen_md5(*args):
return hashlib.md5("".join(args).encode('utf-8')).hexdigest()

View File

@@ -3,9 +3,10 @@ import time
import unittest
import requests
from tests.api_server import FLASK_APP_PORT, HTTPBIN_HOST, HTTPBIN_PORT
from tests.api_server import app as flask_app
from tests.api_server import gen_md5, gen_random_string, get_sign, httpbin_app
from tests.api_server import gen_random_string, get_sign, httpbin_app
def run_flask():

View File

@@ -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

View File

@@ -1,6 +1,3 @@
import random
import requests
from tests.base import ApiServerUnittest

View File

@@ -1,5 +1,4 @@
from httprunner.client import HttpSession
from httprunner.compat import bytes
from tests.api_server import HTTPBIN_SERVER
from tests.base import ApiServerUnittest

View File

@@ -1,8 +1,8 @@
import os
import time
from httprunner import context, exceptions, loader, parser, runner
from tests.base import ApiServerUnittest, gen_md5, gen_random_string
from tests.api_server import gen_md5
from tests.base import ApiServerUnittest, gen_random_string
class TestContext(ApiServerUnittest):

View File

@@ -2,7 +2,7 @@
import os
import unittest
from httprunner import exceptions, loader, validator
from httprunner import exceptions, loader
class TestFileLoader(unittest.TestCase):

View File

@@ -1,4 +1,5 @@
import requests
from httprunner import built_in, exceptions, loader, response
from httprunner.compat import basestring, bytes
from tests.api_server import HTTPBIN_SERVER

View File

@@ -2,7 +2,7 @@ import io
import os
import shutil
from httprunner import exceptions, loader, parser, utils
from httprunner import exceptions, loader, utils
from tests.base import ApiServerUnittest