mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
move api_server start and terminate to class method in order to start api_server only once
This commit is contained in:
+12
-5
@@ -8,19 +8,26 @@ class TestApiServer(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
Test case class that sets up an HTTP server which can be used within the tests
|
Test case class that sets up an HTTP server which can be used within the tests
|
||||||
"""
|
"""
|
||||||
def setUp(self):
|
@classmethod
|
||||||
super(TestApiServer, self).setUp()
|
def setUpClass(cls):
|
||||||
self.api_server_process = multiprocessing.Process(
|
cls.api_server_process = multiprocessing.Process(
|
||||||
target=api_server.app.run
|
target=api_server.app.run
|
||||||
)
|
)
|
||||||
self.api_server_process.start()
|
cls.api_server_process.start()
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(cls):
|
||||||
|
cls.api_server_process.terminate()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestApiServer, self).setUp()
|
||||||
self.host = "http://127.0.0.1:5000"
|
self.host = "http://127.0.0.1:5000"
|
||||||
self.api_client = requests.Session()
|
self.api_client = requests.Session()
|
||||||
|
self.clear_users()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
super(TestApiServer, self).tearDown()
|
super(TestApiServer, self).tearDown()
|
||||||
self.api_server_process.terminate()
|
|
||||||
|
|
||||||
def clear_users(self):
|
def clear_users(self):
|
||||||
url = "%s/api/users" % self.host
|
url = "%s/api/users" % self.host
|
||||||
|
|||||||
Reference in New Issue
Block a user