Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_should_raises_invalid_python_code_error(self):
with pytest.raises(InvalidPythonCodeError) as excinfo:
CodeEvaluator.evaluate(
"${{response.url == 'abc'}}", {}, is_a_test_case=True
)
assert (
str(excinfo.value)
== "Invalid Python code defined in the API spec. "
"Exception: 'NoneType' object has no attribute 'url'. "
def test_should_return_assert_results(self, sequence, expected):
assert (
CodeEvaluator.evaluate(sequence, {}, is_a_test_case=True)
== expected
)
def test_should_raises_invalid_python_code_error(self):
with pytest.raises(InvalidPythonCodeError) as excinfo:
CodeEvaluator.evaluate("${{1/0}}", {})
assert (
str(excinfo.value)
== "Invalid Python code defined in the API spec. "
"Exception: division by zero. Code: 1/0."
def test_should_return_sequence(self, sequence):
assert CodeEvaluator.evaluate(sequence, {}) == sequence
def test_should_return_assert_results(
self, sequence, expected, response
):
assert (
CodeEvaluator.evaluate(
sequence, {"response": response}, is_a_test_case=True
)
== expected
)
def test_should_return_evaluated_code(self, sequence, expected):
assert CodeEvaluator.evaluate(sequence, {}) == expected