mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 07:26:55 +08:00
bugfix #53: ensure teardown functions executed when test fail
This commit is contained in:
@@ -1 +1 @@
|
|||||||
__version__ = '0.8.1c'
|
__version__ = '0.8.1d'
|
||||||
@@ -138,8 +138,8 @@ class Runner(object):
|
|||||||
err_msg += u"HTTP response content: \n{}".format(resp.text)
|
err_msg += u"HTTP response content: \n{}".format(resp.text)
|
||||||
logging.error(err_msg)
|
logging.error(err_msg)
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
setup_teardown(teardown_actions)
|
setup_teardown(teardown_actions)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
from httprunner import exception, runner, testcase
|
from httprunner import exception, runner, testcase
|
||||||
|
|
||||||
@@ -58,11 +59,16 @@ class TestRunner(ApiServerUnittest):
|
|||||||
"validate": [
|
"validate": [
|
||||||
{"check": "status_code", "expect": 205},
|
{"check": "status_code", "expect": 205},
|
||||||
{"check": "content.token", "comparator": "len_eq", "expect": 19}
|
{"check": "content.token", "comparator": "len_eq", "expect": 19}
|
||||||
]
|
],
|
||||||
|
"teardown": ["${sleep(2)}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
with self.assertRaises(exception.ValidationError):
|
with self.assertRaises(exception.ValidationError):
|
||||||
|
start_time = time.time()
|
||||||
self.test_runner._run_test(test)
|
self.test_runner._run_test(test)
|
||||||
|
end_time = time.time()
|
||||||
|
# check if teardown function executed
|
||||||
|
self.assertGreater(end_time - start_time, 2)
|
||||||
|
|
||||||
def test_run_testset_hardcode(self):
|
def test_run_testset_hardcode(self):
|
||||||
for testcase_file_path in self.testcase_file_path_list:
|
for testcase_file_path in self.testcase_file_path_list:
|
||||||
|
|||||||
Reference in New Issue
Block a user