Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _process_result(self, status):
if status == TestStatus.ERROR:
session.increment_errors()
return
if status == TestStatus.FAILED:
session.increment_failures()
return
if status == TestStatus.PASSED:
session.increment_successes()
def _process_result(self, status):
if status == TestStatus.ERROR:
session.increment_errors()
return
if status == TestStatus.FAILED:
session.increment_failures()
return
if status == TestStatus.PASSED:
session.increment_successes()
def run(self):
try:
passed, failure = self.request.endpoint.vars.evaluate_assertion(
self.assertion
)
status = TestStatus.PASSED if passed else TestStatus.FAILED
error = None
except Exception as e:
status = TestStatus.ERROR
failure = None
error = str(e)
self._process_result(status)
self._log_result(status, failure)
return {
"name": self.full_name,
"status": status,
"failure": failure,
"error": error,
}
def run(self):
try:
passed, failure = self.request.endpoint.vars.evaluate_assertion(
self.assertion
)
status = TestStatus.PASSED if passed else TestStatus.FAILED
error = None
except Exception as e:
status = TestStatus.ERROR
failure = None
error = str(e)
self._process_result(status)
self._log_result(status, failure)
return {
"name": self.full_name,
"status": status,
"failure": failure,
"error": error,
}
def _process_result(self, status):
if status == TestStatus.ERROR:
session.increment_errors()
return
if status == TestStatus.FAILED:
session.increment_failures()
return
if status == TestStatus.PASSED:
session.increment_successes()
allow_redirects=False,
)
self.endpoint.vars.update(
self.spec.get(VARS_KEY, {}), extras={"response": response}, preevaluate=True
)
tests_results = self._run_tests()
hide_sensitive_info(response)
return {
"response": response,
"tests_results": tests_results,
"no_failure": all(
[
test_result["status"] == TestStatus.PASSED
for test_result in tests_results
]