mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
replace online httpbin service with httpbin lib
This commit is contained in:
@@ -14,6 +14,7 @@ requests-toolbelt = "*"
|
|||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
flask = "*"
|
flask = "*"
|
||||||
|
httpbin = "*"
|
||||||
coverage = "*"
|
coverage = "*"
|
||||||
coveralls = "*"
|
coveralls = "*"
|
||||||
twine = "*"
|
twine = "*"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
__title__ = 'HttpRunner'
|
__title__ = 'HttpRunner'
|
||||||
__description__ = 'One-stop solution for HTTP(S) testing.'
|
__description__ = 'One-stop solution for HTTP(S) testing.'
|
||||||
__url__ = 'https://github.com/HttpRunner/HttpRunner'
|
__url__ = 'https://github.com/HttpRunner/HttpRunner'
|
||||||
__version__ = '1.4.0.beta'
|
__version__ = '1.4.0.beta.2'
|
||||||
__author__ = 'debugtalk'
|
__author__ = 'debugtalk'
|
||||||
__author_email__ = 'mail@debugtalk.com'
|
__author_email__ = 'mail@debugtalk.com'
|
||||||
__license__ = 'MIT'
|
__license__ = 'MIT'
|
||||||
|
|||||||
+18
-7
@@ -3,12 +3,18 @@ import time
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from httpbin import app as httpbin_app
|
||||||
from httprunner import utils
|
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():
|
def run_flask():
|
||||||
api_server.app.run()
|
flask_app.run(port=FLASK_APP_PORT)
|
||||||
|
|
||||||
|
def run_httpbin():
|
||||||
|
httpbin_app.run(port=HTTPBIN_APP_PORT)
|
||||||
|
|
||||||
|
|
||||||
class ApiServerUnittest(unittest.TestCase):
|
class ApiServerUnittest(unittest.TestCase):
|
||||||
@@ -18,16 +24,21 @@ class ApiServerUnittest(unittest.TestCase):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
cls.host = "http://127.0.0.1:5000"
|
cls.host = "http://127.0.0.1:5000"
|
||||||
cls.api_server_process = multiprocessing.Process(
|
cls.flask_process = multiprocessing.Process(
|
||||||
target=apprun
|
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)
|
time.sleep(0.1)
|
||||||
cls.api_client = requests.Session()
|
cls.api_client = requests.Session()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
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):
|
def get_token(self, user_agent, device_sn, os_platform, app_version):
|
||||||
url = "%s/api/get-token" % self.host
|
url = "%s/api/get-token" % self.host
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
- config:
|
- config:
|
||||||
name: basic test with httpbin
|
name: basic test with httpbin
|
||||||
request:
|
request:
|
||||||
base_url: https://httpbin.org/
|
base_url: http://127.0.0.1:3458/
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: headers
|
name: headers
|
||||||
@@ -13,4 +13,4 @@
|
|||||||
- setup_hook_remove_kwargs
|
- setup_hook_remove_kwargs
|
||||||
validate:
|
validate:
|
||||||
- eq: ["status_code", 200]
|
- eq: ["status_code", 200]
|
||||||
- eq: [content.headers.Host, "httpbin.org"]
|
- eq: [content.headers.Host, "127.0.0.1:3458"]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
- config:
|
- config:
|
||||||
name: load images
|
name: load images
|
||||||
request:
|
request:
|
||||||
base_url: https://httpbin.org
|
base_url: http://127.0.0.1:3458
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: get png image
|
name: get png image
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
- config:
|
- config:
|
||||||
name: test upload file with httpbin
|
name: test upload file with httpbin
|
||||||
request:
|
request:
|
||||||
base_url: https://httpbin.org
|
base_url: http://127.0.0.1:3458
|
||||||
|
|
||||||
- test:
|
- test:
|
||||||
name: upload file
|
name: upload file
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
{
|
{
|
||||||
"name": "post data",
|
"name": "post data",
|
||||||
"request": {
|
"request": {
|
||||||
"url": "https://httpbin.org/post",
|
"url": "http://127.0.0.1:3458/post",
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"headers": {
|
"headers": {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
|
|||||||
Reference in New Issue
Block a user