fix #327: handle teardown hooks when exception occured in initilization

This commit is contained in:
debugtalk
2018-08-02 10:22:38 +08:00
parent da23e3daf4
commit 3bc4c9b3dc

View File

@@ -14,16 +14,17 @@ class Runner(object):
self.context = Context()
config_dict = config_dict or {}
self.init_config(config_dict, "testset")
# testset setup hooks
testset_setup_hooks = config_dict.pop("setup_hooks", [])
if testset_setup_hooks:
self.do_hook_actions(testset_setup_hooks)
# testset teardown hooks
self.testset_teardown_hooks = config_dict.pop("teardown_hooks", [])
self.init_config(config_dict, "testset")
if testset_setup_hooks:
self.do_hook_actions(testset_setup_hooks)
def __del__(self):
if self.testset_teardown_hooks:
self.do_hook_actions(self.testset_teardown_hooks)