diff --git a/Pipfile b/Pipfile index adfed968..20e0a697 100644 --- a/Pipfile +++ b/Pipfile @@ -14,6 +14,7 @@ requests-toolbelt = "*" [dev-packages] flask = "*" +httpbin = "*" coverage = "*" coveralls = "*" twine = "*" diff --git a/httprunner/__about__.py b/httprunner/__about__.py index a1b97cc9..6679e62f 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.4.0.beta' +__version__ = '1.4.0.beta.2' __author__ = 'debugtalk' __author_email__ = 'mail@debugtalk.com' __license__ = 'MIT' diff --git a/tests/base.py b/tests/base.py index cf5d8533..ca7c96be 100644 --- a/tests/base.py +++ b/tests/base.py @@ -3,12 +3,18 @@ import time import unittest import requests +from httpbin import app as httpbin_app from httprunner import utils -from tests import api_server +from tests.api_server import app as flask_app +FLASK_APP_PORT = 5000 +HTTPBIN_APP_PORT = 3458 -def apprun(): - api_server.app.run() +def run_flask(): + flask_app.run(port=FLASK_APP_PORT) + +def run_httpbin(): + httpbin_app.run(port=HTTPBIN_APP_PORT) class ApiServerUnittest(unittest.TestCase): @@ -18,16 +24,21 @@ class ApiServerUnittest(unittest.TestCase): @classmethod def setUpClass(cls): cls.host = "http://127.0.0.1:5000" - cls.api_server_process = multiprocessing.Process( - target=apprun + cls.flask_process = multiprocessing.Process( + target=run_flask ) - cls.api_server_process.start() + cls.httpbin_process = multiprocessing.Process( + target=run_httpbin + ) + cls.flask_process.start() + cls.httpbin_process.start() time.sleep(0.1) cls.api_client = requests.Session() @classmethod def tearDownClass(cls): - cls.api_server_process.terminate() + cls.flask_process.terminate() + cls.httpbin_process.terminate() def get_token(self, user_agent, device_sn, os_platform, app_version): url = "%s/api/get-token" % self.host diff --git a/tests/httpbin/hooks.yml b/tests/httpbin/hooks.yml index bdb5a11a..67cd3339 100644 --- a/tests/httpbin/hooks.yml +++ b/tests/httpbin/hooks.yml @@ -1,7 +1,7 @@ - config: name: basic test with httpbin request: - base_url: https://httpbin.org/ + base_url: http://127.0.0.1:3458/ - test: name: headers @@ -13,4 +13,4 @@ - setup_hook_remove_kwargs validate: - eq: ["status_code", 200] - - eq: [content.headers.Host, "httpbin.org"] + - eq: [content.headers.Host, "127.0.0.1:3458"] diff --git a/tests/httpbin/load_image.yml b/tests/httpbin/load_image.yml index 6a131fdd..78c97a52 100644 --- a/tests/httpbin/load_image.yml +++ b/tests/httpbin/load_image.yml @@ -1,7 +1,7 @@ - config: name: load images request: - base_url: https://httpbin.org + base_url: http://127.0.0.1:3458 - test: name: get png image diff --git a/tests/httpbin/upload.yml b/tests/httpbin/upload.yml index 5f182eed..27728949 100644 --- a/tests/httpbin/upload.yml +++ b/tests/httpbin/upload.yml @@ -1,7 +1,7 @@ - config: name: test upload file with httpbin request: - base_url: https://httpbin.org + base_url: http://127.0.0.1:3458 - test: name: upload file diff --git a/tests/test_httprunner.py b/tests/test_httprunner.py index 992bd775..05b52fbc 100644 --- a/tests/test_httprunner.py +++ b/tests/test_httprunner.py @@ -115,7 +115,7 @@ class TestHttpRunner(ApiServerUnittest): { "name": "post data", "request": { - "url": "https://httpbin.org/post", + "url": "http://127.0.0.1:3458/post", "method": "POST", "headers": { "Content-Type": "application/json"