jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312577?usp=email )

Change subject: tests: Use assertRaisesRegex instead of assertRaises
......................................................................

tests: Use assertRaisesRegex instead of assertRaises

Replace assertRaises with assertRaisesRegex in TestApiTimeoutError so
the tests verify the exception message in addition to its type. This
matters especially for the MaxlagTimeoutError case: because it is a
subclass of ApiTimeoutError, assertRaises alone could not tell the two
apart, whereas matching the message pins down the exact exception.

Bug: T154281
Change-Id: I7974a3081126344698c7b67d166ea550c175094c
---
M tests/exceptions_tests.py
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/tests/exceptions_tests.py b/tests/exceptions_tests.py
index 96d1925..2c36752 100755
--- a/tests/exceptions_tests.py
+++ b/tests/exceptions_tests.py
@@ -28,10 +28,10 @@

     def test_raise_catch(self) -> None:
         """Test raising and catching ApiTimeoutError."""
-        with self.assertRaises(ApiTimeoutError):
+        with self.assertRaisesRegex(ApiTimeoutError, 'Test timeout'):
             raise ApiTimeoutError('Test timeout')

-        with self.assertRaises(ApiTimeoutError):
+        with self.assertRaisesRegex(ApiTimeoutError, 'Test maxlag timeout'):
             raise MaxlagTimeoutError('Test maxlag timeout')



--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1312577?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I7974a3081126344698c7b67d166ea550c175094c
Gerrit-Change-Number: 1312577
Gerrit-PatchSet: 1
Gerrit-Owner: Sydneynoh <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to