Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
given by os.linesep. If newline is '', no translation takes place. If newline is any of
the other legal values, any '\n' characters written are translated to the given string.
Raises:
ApprovalException: If the verification fails because the given string does not match the
approved string.
ValueError: If data cannot be encoded using the specified encoding when errors is set to
None or 'strict'.
"""
reporter = get_reporter(reporter)
approver = FileApprover()
writer = StringWriter(data, encoding=encoding, errors=errors, newline=newline)
error = approver.verify(namer, writer, reporter)
if error is not None:
raise ApprovalException(error)
def test_fails_for_mismatch_with_for_func_accepting_one_arg_and_combination_of_one_arg(self):
arg1_combinations = (1,)
all_args_combinations = (arg1_combinations,)
with self.assertRaises(ApprovalException):
verify_all_combinations(self.func, all_args_combinations, reporter=self.reporter)
def test_verify_fail(self):
reporter = ReporterForTesting()
try:
verify("Hello World.", reporter)
self.assertFalse(True, "expected exception")
except ApprovalException as e:
self.assertTrue("Approval Mismatch", e.value)
def test_assert_against_file_fails_with_reporter(self):
reporter = ReporterForTesting()
file_path = get_adjacent_file("manual_file.approved.txt")
try:
assert_against_file("This text is NOT in a file", file_path, reporter )
except ApprovalException:
pass
self.assertTrue(reporter.called)
def test_fails_for_mismatch_with_for_func_accepting_one_arg_and_combination_of_two_args(self):
arg1_combinations = (1, 2)
all_args_combinations = (arg1_combinations,)
with self.assertRaises(ApprovalException):
verify_all_combinations(self.func, all_args_combinations, reporter=self.reporter)