def METHOD_NAME(self, test_cases, logging_func, logger_name, mocker):
    for case in test_cases:
        try:
            logger_mock = mocker.patch(logger_name)
            print_mock = mocker.patch(PRINT_FUNC_STRING)
            mocker.patch("stripe.log", case.flag)
            mocker.patch("stripe.util.STRIPE_LOG", case.env)
            logging_func("foo \nbar", y=3)  # function under test
            if case.should_output:
                print_mock.assert_called_once_with(
                    "message='foo \\nbar' y=3", file=sys.stderr
                )
            else:
                print_mock.assert_not_called()
            logger_mock.assert_called_once_with("message='foo \\nbar' y=3")
        finally:
            mocker.stopall()