From db3fd6947f52e0a1757cef3bc7689e8029a9e400 Mon Sep 17 00:00:00 2001 From: Zixuan James Li Date: Sun, 14 Aug 2022 22:29:21 -0400 Subject: [PATCH] test_decorators: Remove errors_disallowed helper. The said hack was removed in c00aab8ede9add394edc2cbf1bde8985f22e87d6, and rate_limit itself has also been removed. Signed-off-by: Zixuan James Li --- zerver/tests/test_decorators.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 2475bb6645..617e9eeb69 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -642,17 +642,6 @@ class RateLimitTestCase(ZulipTestCase): def ratelimited_web_view(req: HttpRequest) -> HttpResponse: return HttpResponse("some value") - def errors_disallowed(self) -> Any: - # Due to what is probably a hack in rate_limit(), - # some tests will give a false positive (or succeed - # for the wrong reason), unless we complain - # about logging errors. There might be a more elegant way - # make logging errors fail than what I'm doing here. - class TestLoggingErrorException(Exception): - pass - - return mock.patch("logging.error", side_effect=TestLoggingErrorException) - def check_rate_limit_public_or_user_views( self, remote_addr: str, @@ -669,7 +658,7 @@ class RateLimitTestCase(ZulipTestCase): "zerver.lib.rate_limiter.RateLimitedUser" ) as rate_limit_user_mock, mock.patch( "zerver.lib.rate_limiter.rate_limit_ip" - ) as rate_limit_ip_mock, self.errors_disallowed(): + ) as rate_limit_ip_mock: self.assert_in_success_response(["some value"], view_func(request)) self.assertEqual(rate_limit_ip_mock.called, expect_rate_limit) self.assertFalse(rate_limit_user_mock.called) @@ -685,7 +674,7 @@ class RateLimitTestCase(ZulipTestCase): "zerver.lib.rate_limiter.RateLimitedUser" ) as rate_limit_user_mock, mock.patch( "zerver.lib.rate_limiter.rate_limit_ip" - ) as rate_limit_ip_mock, self.errors_disallowed(): + ) as rate_limit_ip_mock: self.assert_in_success_response(["some value"], view_func(request)) self.assertEqual(rate_limit_user_mock.called, expect_rate_limit) self.assertFalse(rate_limit_ip_mock.called)