Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def failure_assertions(self, r):
"""
Assertions for every command that should fail.
"""
assert r.status_code == tm.status_codes.fail
with pytest.raises(tm.TomcatError):
r.raise_for_status()
def docmd(self, func: Callable, *args, **kwargs) -> Any:
"""Call a function and return, printing any exceptions that occur
Sets exit_code to 0 and calls {func}. If func throws a TomcatError,
set exit_code to 1 and print the exception
"""
self.exit_code = self.exit_codes.success
r = func(*args, **kwargs)
try:
r.raise_for_status()
except tm.TomcatError as err:
self.exit_code = self.exit_codes.error
self.perror(str(err))
return r