mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
typing: Avoid scoped redefinition of different types.
Mypy doesn't allow redefinition of a variable using a different type within the same scope. https://github.com/python/mypy/issues/1174
This commit is contained in:
@@ -487,9 +487,9 @@ class StripeTest(StripeTestCase):
|
||||
raise stripe.error.InvalidRequestError("message", "param", "code", json_body={})
|
||||
|
||||
with self.assertLogs("corporate.stripe", "ERROR") as error_log:
|
||||
with self.assertRaises(BillingError) as context:
|
||||
with self.assertRaises(BillingError) as billing_context:
|
||||
raise_invalid_request_error()
|
||||
self.assertEqual("other stripe error", context.exception.error_description)
|
||||
self.assertEqual("other stripe error", billing_context.exception.error_description)
|
||||
self.assertEqual(
|
||||
error_log.output, ["ERROR:corporate.stripe:Stripe error: None None None None"]
|
||||
)
|
||||
@@ -503,10 +503,10 @@ class StripeTest(StripeTestCase):
|
||||
)
|
||||
|
||||
with self.assertLogs("corporate.stripe", "INFO") as info_log:
|
||||
with self.assertRaises(StripeCardError) as context:
|
||||
with self.assertRaises(StripeCardError) as card_context:
|
||||
raise_card_error()
|
||||
self.assertIn("not a valid credit card", str(context.exception))
|
||||
self.assertEqual("card error", context.exception.error_description)
|
||||
self.assertIn("not a valid credit card", str(card_context.exception))
|
||||
self.assertEqual("card error", card_context.exception.error_description)
|
||||
self.assertEqual(
|
||||
info_log.output, ["INFO:corporate.stripe:Stripe card error: None None None None"]
|
||||
)
|
||||
|
||||
@@ -179,14 +179,16 @@ class DecoratorTestCase(ZulipTestCase):
|
||||
self.assertEqual(str(cm.exception), "Bad value for 'numbers': bad_value")
|
||||
|
||||
request.POST["numbers"] = orjson.dumps("{fun: unfun}").decode()
|
||||
with self.assertRaises(JsonableError) as cm:
|
||||
with self.assertRaises(JsonableError) as jsonable_error_cm:
|
||||
get_total(request)
|
||||
self.assertEqual(str(cm.exception), "Bad value for 'numbers': \"{fun: unfun}\"")
|
||||
self.assertEqual(
|
||||
str(jsonable_error_cm.exception), "Bad value for 'numbers': \"{fun: unfun}\""
|
||||
)
|
||||
|
||||
request.POST["numbers"] = orjson.dumps([2, 3, 5, 8, 13, 21]).decode()
|
||||
with self.assertRaises(JsonableError) as cm:
|
||||
with self.assertRaises(JsonableError) as jsonable_error_cm:
|
||||
get_total(request)
|
||||
self.assertEqual(str(cm.exception), "13 is an unlucky number!")
|
||||
self.assertEqual(str(jsonable_error_cm.exception), "13 is an unlucky number!")
|
||||
|
||||
request.POST["numbers"] = orjson.dumps([1, 2, 3, 4, 5, 6]).decode()
|
||||
result = get_total(request)
|
||||
|
||||
@@ -295,7 +295,7 @@ class PermissionTest(ZulipTestCase):
|
||||
"zerver.lib.events.request_event_queue", return_value=None
|
||||
) as mock_request_event_queue:
|
||||
with self.assertRaises(JsonableError):
|
||||
result = do_events_register(user, get_client("website"), client_gravatar=True)
|
||||
do_events_register(user, get_client("website"), client_gravatar=True)
|
||||
self.assertEqual(mock_request_event_queue.call_args_list[0][0][3], True)
|
||||
|
||||
#############################################################
|
||||
|
||||
Reference in New Issue
Block a user