diff --git a/ckanext/subscribe/tests/test_action.py b/ckanext/subscribe/tests/test_action.py index afc8d60..60af1ca 100644 --- a/ckanext/subscribe/tests/test_action.py +++ b/ckanext/subscribe/tests/test_action.py @@ -288,17 +288,21 @@ def test_verify_recaptcha_failure( dataset_id=dataset["id"], g_recaptcha_response="invalid-recaptcha-response", ) - except ValidationError as cm: + except Exception as cm: + print("Exception type: {}".format(type(cm).__name__)) + print("Exception message: {}".format(cm)) # Asserting that the error is raised due to invalid reCAPTCHA - assert_in( - 'Invalid reCAPTCHA response: "g_recaptcha_response"', - str(cm.exception.error_dict), - ) - - assert not send_request_email.called - - # Ensuring the email is not sent due to invalid reCAPTCHA - assert not send_request_email.called + if isinstance(cm, ValidationError): + assert_in( + 'Invalid reCAPTCHA response: "g_recaptcha_response"', + str(cm.exception.error_dict), + ) + + # Ensuring the email is not sent due to invalid reCAPTCHA + assert not send_request_email.called + else: + # Re-raise the exception if it's not a ValidationError + raise else: assert False, "ValidationError not raised"