From 6bb9088a0b11e71f444613ceba361beb84e94558 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 10 Sep 2018 07:49:02 +0800 Subject: [PATCH 1/3] fix unittest for httpbin response time --- tests/test_api.py | 2 +- tests/test_response.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 010d2ec8..9484c50a 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -173,7 +173,7 @@ class TestHttpRunner(ApiServerUnittest): end_time = time.time() summary = runner.summary self.assertTrue(summary["success"]) - self.assertLess(end_time - start_time, 20) + self.assertLess(end_time - start_time, 60) def test_run_httprunner_with_teardown_hooks_alter_response(self): testcases = [ diff --git a/tests/test_response.py b/tests/test_response.py index bc02ebd5..c54058ae 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -136,7 +136,7 @@ class TestResponse(ApiServerUnittest): ] extract_binds_dict = resp_obj.extract_response(extract_binds_list) self.assertGreater(extract_binds_dict["resp_elapsed_microseconds"], 1000) - self.assertLess(extract_binds_dict["resp_elapsed_seconds"], 10) + self.assertLess(extract_binds_dict["resp_elapsed_seconds"], 60) self.assertEqual(extract_binds_dict["resp_elapsed_days"], 0) self.assertGreater(extract_binds_dict["resp_elapsed_total_seconds"], 0) From 9993bb7b819e7319db7c7afaded1d39a28eeb28b Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 17 Sep 2018 15:16:35 +0800 Subject: [PATCH 2/3] fix #392: multiple '=' in .env file --- httprunner/loader.py | 4 ++-- tests/data/test.env | 3 ++- tests/test_loader.py | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/httprunner/loader.py b/httprunner/loader.py index 75d8e535..07761bcf 100644 --- a/httprunner/loader.py +++ b/httprunner/loader.py @@ -192,9 +192,9 @@ def load_dot_env_file(): with io.open(path, 'r', encoding='utf-8') as fp: for line in fp: if "=" in line: - variable, value = line.split("=") + variable, value = line.split("=", maxsplit=1) elif ":" in line: - variable, value = line.split(":") + variable, value = line.split(":", maxsplit=1) else: raise exceptions.FileFormatError(".env format error") diff --git a/tests/data/test.env b/tests/data/test.env index 09816d83..74d5d9ec 100644 --- a/tests/data/test.env +++ b/tests/data/test.env @@ -1,3 +1,4 @@ UserName=test Password=654321 -PROJECT_KEY=AAABBBCCC \ No newline at end of file +PROJECT_KEY=AAABBBCCC +content_type=application/json; charset=UTF-8 \ No newline at end of file diff --git a/tests/test_loader.py b/tests/test_loader.py index 18e67d86..03f8e4e0 100644 --- a/tests/test_loader.py +++ b/tests/test_loader.py @@ -148,6 +148,7 @@ class TestFileLoader(unittest.TestCase): env_variables_mapping = loader.load_dot_env_file() self.assertIn("PROJECT_KEY", env_variables_mapping) self.assertEqual(env_variables_mapping["UserName"], "test") + self.assertEqual(env_variables_mapping["content_type"], "application/json; charset=UTF-8") loader.dot_env_path = None def test_load_env_path_not_exist(self): From 96a1ab4f57c8fca059b3d0bfb7399de1ead4497f Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 20 Sep 2018 19:17:06 +0800 Subject: [PATCH 3/3] fix #155: escape validators --- httprunner/templates/report_template.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httprunner/templates/report_template.html b/httprunner/templates/report_template.html index 79bf2c0e..62b8a208 100644 --- a/httprunner/templates/report_template.html +++ b/httprunner/templates/report_template.html @@ -315,11 +315,11 @@ {% elif validator.check_result == "unchecked" %} {% endif %} - {{validator.check}} + {{validator.check | e}} {{validator.comparator}} - {{validator.expect}} - {{validator.check_value}} + {{validator.expect | e}} + {{validator.check_value | e}} {% endfor %}