fix Python version compability

This commit is contained in:
debugtalk
2018-05-03 15:13:25 +08:00
parent d08acfd4bf
commit 37a6615791
6 changed files with 92 additions and 4 deletions

View File

@@ -18,5 +18,6 @@ httpbin = "*"
coverage = "*"
coveralls = "*"
twine = "*"
"contextlib2" = "*"
[scripts]

76
Pipfile.lock generated
View File

@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "c302cef3ca18b5461e37d0397de08ae4603f3f10b961fda2c2a4d875f473e9b8"
"sha256": "d7f64497b3d793a5f3631335475c732372f2e10e25639f408b679f818464c12a"
},
"pipfile-spec": 6,
"requires": {},
@@ -117,6 +117,13 @@
}
},
"develop": {
"asn1crypto": {
"hashes": [
"sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87",
"sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49"
],
"version": "==0.24.0"
},
"blinker": {
"hashes": [
"sha256:471aee25f3992bd325afa3772f1063dbdbbca947a041b8b89466dc00d606f8b6"
@@ -194,6 +201,7 @@
"sha256:edabd457cd23a02965166026fd9bfd196f4324fe6032e866d0f3bd0301cd486f",
"sha256:fdf1c1dc5bafc32bc5d08b054f94d659422b05aba244d6be4ddc1c72d9aa70fb"
],
"markers": "platform_python_implementation != 'PyPy'",
"version": "==1.11.5"
},
"chardet": {
@@ -218,6 +226,14 @@
"index": "pypi",
"version": "==0.3.9"
},
"contextlib2": {
"hashes": [
"sha256:509f9419ee91cdd00ba34443217d5ca51f5a364a404e1dce9e8979cea969ca48",
"sha256:f5260a6e679d2ff42ec91ec5252f4eeffdcf21053db9113bd0a8e4d953769c00"
],
"index": "pypi",
"version": "==0.5.5"
},
"coverage": {
"hashes": [
"sha256:03481e81d558d30d230bc12999e3edffe392d244349a90f4ef9b88425fac74ba",
@@ -275,6 +291,28 @@
],
"version": "==0.1.2"
},
"cryptography": {
"hashes": [
"sha256:3f3b65d5a16e6b52fba63dc860b62ca9832f51f1a2ae5083c78b6840275f12dd",
"sha256:551a3abfe0c8c6833df4192a63371aa2ff43afd8f570ed345d31f251d78e7e04",
"sha256:5cb990056b7cadcca26813311187ad751ea644712022a3976443691168781b6f",
"sha256:60bda7f12ecb828358be53095fc9c6edda7de8f1ef571f96c00b2363643fa3cd",
"sha256:6fef51ec447fe9f8351894024e94736862900d3a9aa2961528e602eb65c92bdb",
"sha256:77d0ad229d47a6e0272d00f6bf8ac06ce14715a9fd02c9a97f5a2869aab3ccb2",
"sha256:808fe471b1a6b777f026f7dc7bd9a4959da4bfab64972f2bbe91e22527c1c037",
"sha256:9b62fb4d18529c84b961efd9187fecbb48e89aa1a0f9f4161c61b7fc42a101bd",
"sha256:9e5bed45ec6b4f828866ac6a6bedf08388ffcfa68abe9e94b34bb40977aba531",
"sha256:9fc295bf69130a342e7a19a39d7bbeb15c0bcaabc7382ec33ef3b2b7d18d2f63",
"sha256:abd070b5849ed64e6d349199bef955ee0ad99aefbad792f0c587f8effa681a5e",
"sha256:ba6a774749b6e510cffc2fb98535f717e0e5fd91c7c99a61d223293df79ab351",
"sha256:c332118647f084c983c6a3e1dba0f3bcb051f69d12baccac68db8d62d177eb8a",
"sha256:d6f46e862ee36df81e6342c2177ba84e70f722d9dc9c6c394f9f1f434c4a5563",
"sha256:db6013746f73bf8edd9c3d1d3f94db635b9422f503db3fc5ef105233d4c011ab",
"sha256:f57008eaff597c69cf692c3518f6d4800f0309253bb138b526a37fe9ef0c7471",
"sha256:f6c821ac253c19f2ad4c8691633ae1d1a17f120d5b01ea1d256d7b602bc59887"
],
"version": "==2.2.2"
},
"dateparser": {
"hashes": [
"sha256:940828183c937bcec530753211b70f673c0a9aab831e43273489b310538dff86",
@@ -295,6 +333,16 @@
],
"version": "==0.6.2"
},
"enum34": {
"hashes": [
"sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850",
"sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a",
"sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79",
"sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1"
],
"markers": "python_version < '3'",
"version": "==1.1.6"
},
"flask": {
"hashes": [
"sha256:2ea22336f6d388b4b242bc3abf8a01244a8aa3e236e7407469ef78c16ba355dd",
@@ -374,6 +422,14 @@
],
"version": "==2.6"
},
"ipaddress": {
"hashes": [
"sha256:64b28eec5e78e7510698f6d4da08800a5c575caa4a286c93d651c5d3ff7b6794",
"sha256:b146c751ea45cad6188dd6cf2d9b757f6f4f8d6ffb96a023e6f2e26eea02a72c"
],
"markers": "python_version < '3'",
"version": "==1.0.22"
},
"itsdangerous": {
"hashes": [
"sha256:cbb3fcf8d3e33df861709ecaf89d9e6629cff0a217bc2848f1b41cd30d360519"
@@ -443,6 +499,13 @@
],
"version": "==2.18"
},
"pyopenssl": {
"hashes": [
"sha256:07a2de1a54de07448732a81e38a55df7da109b2f47f599f8bb35b0cbec69d4bd",
"sha256:2c10cfba46a52c0b0950118981d61e72c1e5b1aac451ca1bc77de1a679456773"
],
"version": "==17.5.0"
},
"python-dateutil": {
"hashes": [
"sha256:3220490fb9741e2342e1cf29a503394fdac874bc39568288717ee67047ff29df",
@@ -507,6 +570,17 @@
"index": "pypi",
"version": "==0.8.0"
},
"ruamel.ordereddict": {
"hashes": [
"sha256:08b4b19fe518d32251a5338e039c4dc9eb0876f2919f94c9b8d2f9446ea80806",
"sha256:150ce8e6c514a2a2b62753622a75874962561f8e5eeec81a3172ab952807bf0b",
"sha256:45541836cbfdde630033cae7bbbe35acbac87a0ceec79f944b7a3bedd940fe78",
"sha256:aee2fa23e884249b4284b728888c553d551e5bfd4de2731f10153fd7813ec55f",
"sha256:bf0a198c8ce5d973c24e5dba12d3abc254996788ca6ad8448eabc6aa710db149"
],
"markers": "platform_python_implementation == 'cpython' and python_version <= '2.7'",
"version": "==0.4.13"
},
"ruamel.yaml": {
"hashes": [
"sha256:039bb5b50a2f3b17c969ed1d381e050bca851e3c13fe8c2a9ad18f605ca111a5",

View File

@@ -107,6 +107,7 @@ class TestcaseLoader(object):
}
testcases_cache_mapping = {}
@staticmethod
def load_test_dependencies():
""" load all api and suite definitions.
default api folder is "$CWD/tests/api/".
@@ -130,6 +131,7 @@ class TestcaseLoader(object):
suite["function_meta"] = function_meta
TestcaseLoader.overall_def_dict["suite"][function_meta["func_name"]] = suite
@staticmethod
def load_api_file(file_path):
""" load api definition from file and store in overall_def_dict["api"]
api file should be in format below:
@@ -172,6 +174,7 @@ class TestcaseLoader(object):
api_dict["function_meta"] = function_meta
TestcaseLoader.overall_def_dict["api"][func_name] = api_dict
@staticmethod
def load_test_file(file_path):
""" load testcase file or suite file
@param file_path: absolute valid file path
@@ -245,6 +248,7 @@ class TestcaseLoader(object):
return testset
@staticmethod
def _get_block_by_name(ref_call, ref_type):
""" get test content by reference name
@params:
@@ -272,6 +276,7 @@ class TestcaseLoader(object):
return block
@staticmethod
def _get_test_definition(name, ref_type):
""" get expected api or suite.
@params:
@@ -292,6 +297,7 @@ class TestcaseLoader(object):
return block
@staticmethod
def _override_block(def_block, current_block):
""" override def_block with current_block
@param def_block:
@@ -334,6 +340,7 @@ class TestcaseLoader(object):
current_extractors
)
@staticmethod
def load_testsets_by_path(path):
""" load testcases from file path
@param path: path could be in several type

View File

@@ -46,6 +46,7 @@ def remove_prefix(text, prefix):
class FileUtils(object):
@staticmethod
def _check_format(file_path, content):
""" check testcase format if valid
"""
@@ -61,6 +62,7 @@ class FileUtils(object):
logger.log_error(err_msg)
raise exception.FileFormatError(err_msg)
@staticmethod
def _load_yaml_file(yaml_file):
""" load yaml file and check file content format
"""
@@ -69,6 +71,7 @@ class FileUtils(object):
FileUtils._check_format(yaml_file, yaml_content)
return yaml_content
@staticmethod
def _load_json_file(json_file):
""" load json file and check file content format
"""
@@ -83,6 +86,7 @@ class FileUtils(object):
FileUtils._check_format(json_file, json_content)
return json_content
@staticmethod
def _load_csv_file(csv_file):
""" load csv file and check file content format
@param
@@ -110,6 +114,7 @@ class FileUtils(object):
return csv_content_list
@staticmethod
def load_file(file_path):
if not os.path.isfile(file_path):
raise exception.FileNotFoundError("{} does not exist.".format(file_path))
@@ -127,6 +132,7 @@ class FileUtils(object):
logger.log_warning(err_msg)
return []
@staticmethod
def load_folder_files(folder_path, recursive=True):
""" load folder path, return all files in list format.
@param

View File

@@ -97,8 +97,8 @@ class TestTestcaseLoader(unittest.TestCase):
TestcaseLoader._override_block(def_block, test_block)
self.assertEqual(test_block["name"], "override block")
self.assertEqual(test_block["validate"][0], {'check': 'status_code', 'expect': 201, 'comparator': 'eq'})
self.assertEqual(test_block["validate"][1], {'check': 'content.token', 'comparator': 'len_eq', 'expect': 32})
self.assertIn({'check': 'status_code', 'expect': 201, 'comparator': 'eq'}, test_block["validate"])
self.assertIn({'check': 'content.token', 'comparator': 'len_eq', 'expect': 32}, test_block["validate"])
def test_load_testcases_by_path_files(self):
testsets_list = []

View File

@@ -62,7 +62,7 @@ class TestFileUtils(unittest.TestCase):
def test_load_testcases_bad_filepath(self):
testcase_file_path = os.path.join(os.getcwd(), 'tests/data/demo')
with self.assertRaises(FileNotFoundError):
with self.assertRaises(exception.FileNotFoundError):
FileUtils.load_file(testcase_file_path)
def test_load_json_testcases(self):