lfcli_base.py: introduces exit_on_error, exit_on_fail

This commit is contained in:
Jed Reynolds
2020-06-09 16:46:46 -07:00
parent 78838dd827
commit 9692fe45d1

View File

@@ -12,7 +12,7 @@ class LFCliBase:
# do not use `super(LFCLiBase,self).__init__(self, host, port, _debugOn) # do not use `super(LFCLiBase,self).__init__(self, host, port, _debugOn)
# that is py2 era syntax and will force self into the host variable, making you # that is py2 era syntax and will force self into the host variable, making you
# very confused. # very confused.
def __init__(self, _lfjson_host, _lfjson_port, _debug=False, _halt_on_error=False): def __init__(self, _lfjson_host, _lfjson_port, _debug=False, _halt_on_error=False, _exit_on_error=False, _exit_on_fail=False):
self.fail_pref = "FAILED: " self.fail_pref = "FAILED: "
self.pass_pref = "PASSED: " self.pass_pref = "PASSED: "
self.lfjson_host = _lfjson_host self.lfjson_host = _lfjson_host
@@ -21,6 +21,8 @@ class LFCliBase:
self.haltOnError = _halt_on_error self.haltOnError = _halt_on_error
self.lfclient_url = "http://%s:%s" % (self.lfjson_host, self.lfjson_port) self.lfclient_url = "http://%s:%s" % (self.lfjson_host, self.lfjson_port)
self.test_results = [] self.test_results = []
self.exit_on_error = _exit_on_error
self.exit_on_fail = _exit_on_fail
def clear_test_results(self): def clear_test_results(self):
self.test_results.clear() self.test_results.clear()
@@ -122,6 +124,8 @@ class LFCliBase:
self.test_results.append(self.fail_pref + message) self.test_results.append(self.fail_pref + message)
if print_: if print_:
print(self.fail_pref + message) print(self.fail_pref + message)
if self.exit_on_error:
sys.exit(1)
# use this inside the class to log a pass result # use this inside the class to log a pass result
def _pass(self, message, print_=False): def _pass(self, message, print_=False):