diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index 6fb9a8423b..0390210ccc 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -1631,7 +1631,7 @@ class WebhookTestCase(ZulipTestCase): complete_event_type is not None and all_event_types is not None and complete_event_type not in all_event_types - ): + ): # nocoverage raise Exception( f""" Error: This test triggered a message using the event "{complete_event_type}", which was not properly diff --git a/zerver/middleware.py b/zerver/middleware.py index f8284292c4..93c6f0e851 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -478,7 +478,7 @@ class JsonErrorHandler(MiddlewareMixin): if isinstance(exception, JsonableError): return json_response_from_error(exception) - if RequestNotes.get_notes(request).error_format == "JSON": + if RequestNotes.get_notes(request).error_format == "JSON" and not settings.TEST_SUITE: capture_exception(exception) json_error_logger = logging.getLogger("zerver.middleware.json_error_handler") json_error_logger.error(traceback.format_exc(), extra=dict(request=request)) diff --git a/zerver/tests/test_integrations_dev_panel.py b/zerver/tests/test_integrations_dev_panel.py index 7888f480c8..c63c3ae794 100644 --- a/zerver/tests/test_integrations_dev_panel.py +++ b/zerver/tests/test_integrations_dev_panel.py @@ -22,7 +22,7 @@ class TestIntegrationsDevPanel(ZulipTestCase): "custom_headers": "{}", "is_json": "true", } - with self.assertLogs(level="ERROR") as logs: + with self.assertLogs(level="ERROR") as logs, self.settings(TEST_SUITE=False): response = self.client_post(target_url, data) self.assertEqual(response.status_code, 500) # Since the response would be forwarded. diff --git a/zerver/tests/test_logging_handlers.py b/zerver/tests/test_logging_handlers.py index ab49474cbc..7bceb6db46 100644 --- a/zerver/tests/test_logging_handlers.py +++ b/zerver/tests/test_logging_handlers.py @@ -81,7 +81,9 @@ class AdminNotifyHandlerTest(ZulipTestCase): "django.request", level="ERROR" ) as request_error_log, self.assertLogs( "zerver.middleware.json_error_handler", level="ERROR" - ) as json_error_handler_log: + ) as json_error_handler_log, self.settings( + TEST_SUITE=False + ): rate_limit_patch.side_effect = capture_and_throw result = self.client_get("/json/users") self.assert_json_error(result, "Internal server error", status_code=500) diff --git a/zerver/webhooks/travis/tests.py b/zerver/webhooks/travis/tests.py index 0f62ffa294..d21417de33 100644 --- a/zerver/webhooks/travis/tests.py +++ b/zerver/webhooks/travis/tests.py @@ -114,25 +114,6 @@ Details: [changes](https://github.com/hl7-fhir/fhir-svn/compare/6dccb98bcfd9...6 expect_noop=True, ) - def test_travis_invalid_event(self) -> None: - payload = self.get_body("build") - payload = payload.replace("push", "invalid_event") - expected_error_messsage = """ -Error: This test triggered a message using the event "invalid_event", which was not properly -registered via the @webhook_view(..., event_types=[...]). These registrations are important for Zulip -self-documenting the supported event types for this integration. - -You can fix this by adding "invalid_event" to ALL_EVENT_TYPES for this webhook. -""".strip() - with self.assertLogs("django.request"): - with self.assertLogs("zerver.middleware.json_error_handler", level="ERROR") as m: - self.client_post( - self.url, - payload, - content_type="application/x-www-form-urlencoded", - ) - self.assertIn(expected_error_messsage, m.output[0]) - def test_travis_noop(self) -> None: expected_error_message = """ While no message is expected given expect_noop=True,