From 05bca2276f37bcf055572bd8bb0e8347fb12e6ec Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 6 Sep 2018 08:51:47 +0800 Subject: [PATCH 1/2] fix #112: RecursionError when running locust --- httprunner/__about__.py | 2 +- httprunner/__init__.py | 6 ++++++ tests/httpbin/basic.yml | 5 +---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/httprunner/__about__.py b/httprunner/__about__.py index 11a468d0..82a265d0 100644 --- a/httprunner/__about__.py +++ b/httprunner/__about__.py @@ -1,7 +1,7 @@ __title__ = 'HttpRunner' __description__ = 'One-stop solution for HTTP(S) testing.' __url__ = 'https://github.com/HttpRunner/HttpRunner' -__version__ = '1.5.13' +__version__ = '1.5.14' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'MIT' diff --git a/httprunner/__init__.py b/httprunner/__init__.py index 0e26081e..48724cf5 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -1,3 +1,9 @@ # encoding: utf-8 +try: + # monkey patch at beginning to avoid RecursionError when running locust. + from gevent import monkey; monkey.patch_all() +except ImportError: + pass + from httprunner.api import HttpRunner, LocustRunner diff --git a/tests/httpbin/basic.yml b/tests/httpbin/basic.yml index 2c64f175..f8eacca2 100644 --- a/tests/httpbin/basic.yml +++ b/tests/httpbin/basic.yml @@ -1,7 +1,7 @@ - config: name: basic test with httpbin request: - base_url: http://httpbin.org/ + base_url: https://httpbin.org/ - test: name: index @@ -98,6 +98,3 @@ - len_eq: ["content", 9] - len_eq: ["json", 9] - len_eq: ["text", 9] - - - From adf09a27e0ef1df33f36a9085210287863bda007 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 6 Sep 2018 11:52:06 +0800 Subject: [PATCH 2/2] fix unittest --- 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 5af4349c..010d2ec8 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, 10) + self.assertLess(end_time - start_time, 20) def test_run_httprunner_with_teardown_hooks_alter_response(self): testcases = [ diff --git a/tests/test_response.py b/tests/test_response.py index efc8492b..bc02ebd5 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"], 3) + self.assertLess(extract_binds_dict["resp_elapsed_seconds"], 10) self.assertEqual(extract_binds_dict["resp_elapsed_days"], 0) self.assertGreater(extract_binds_dict["resp_elapsed_total_seconds"], 0)