mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
create ApiServerUnittest for public use
This commit is contained in:
20
test/base.py
Normal file
20
test/base.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import multiprocessing
|
||||
import time
|
||||
import unittest
|
||||
from . import api_server
|
||||
|
||||
class ApiServerUnittest(unittest.TestCase):
|
||||
"""
|
||||
Test case class that sets up an HTTP server which can be used within the tests
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.api_server_process = multiprocessing.Process(
|
||||
target=api_server.app.run
|
||||
)
|
||||
cls.api_server_process.start()
|
||||
time.sleep(0.1)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.api_server_process.terminate()
|
||||
@@ -1,25 +1,7 @@
|
||||
import multiprocessing
|
||||
import time
|
||||
import unittest
|
||||
import requests
|
||||
from . import api_server
|
||||
|
||||
class TestApiServer(unittest.TestCase):
|
||||
"""
|
||||
Test case class that sets up an HTTP server which can be used within the tests
|
||||
"""
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.api_server_process = multiprocessing.Process(
|
||||
target=api_server.app.run
|
||||
)
|
||||
cls.api_server_process.start()
|
||||
time.sleep(0.1)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.api_server_process.terminate()
|
||||
from .base import ApiServerUnittest
|
||||
|
||||
class TestApiServer(ApiServerUnittest):
|
||||
def setUp(self):
|
||||
super(TestApiServer, self).setUp()
|
||||
self.host = "http://127.0.0.1:5000"
|
||||
|
||||
Reference in New Issue
Block a user