How to use the approvaltests.approval_exception.ApprovalException function in approvaltests

To help you get started, we’ve selected a few approvaltests examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github approvals / ApprovalTests.Python / approvaltests / approvals.py View on Github external
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)
github approvals / ApprovalTests.Python / tests / test_combinations.py View on Github external
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)
github approvals / ApprovalTests.Python / tests / test_verify.py View on Github external
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)
github approvals / ApprovalTests.Python / tests / test_asserts.py View on Github external
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)
github approvals / ApprovalTests.Python / tests / test_combinations.py View on Github external
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)