mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
replace online httpbin service with httpbin lib
This commit is contained in:
1
Pipfile
1
Pipfile
@@ -14,6 +14,7 @@ requests-toolbelt = "*"
|
||||
|
||||
[dev-packages]
|
||||
flask = "*"
|
||||
httpbin = "*"
|
||||
coverage = "*"
|
||||
coveralls = "*"
|
||||
twine = "*"
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user