Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/631912 )

Change subject: [bugfix] Update TestAPIMWException
......................................................................

[bugfix] Update TestAPIMWException

- Do not have tests in tearDown
- update test_API_error

Bug: T264096
Change-Id: If33fcd52f16f832a020894f4975f1c060dd9f9b4
---
M tests/api_tests.py
1 file changed, 18 insertions(+), 10 deletions(-)

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



diff --git a/tests/api_tests.py b/tests/api_tests.py
index 9895f52..02be034 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -84,16 +84,9 @@

     def tearDown(self):
         """Check warning and error calls."""
-        try:
-            pywikibot.warning.assert_called_with(
-                'API error internal_api_error_fake: Fake error message')
-            pywikibot.error.assert_called_with(
-                'Detected MediaWiki API exception internal_api_error_fake: '
-                'Fake error message\n[servedby: unittest]; raising')
-        finally:
-            self.warning_patcher.stop()
-            self.error_patcher.stop()
-            super(TestAPIMWException, self).tearDown()
+        self.warning_patcher.stop()
+        self.error_patcher.stop()
+        super(TestAPIMWException, self).tearDown()

     def test_API_error(self):
         """Test a static request."""
@@ -101,6 +94,11 @@
                                                       'fake': True})
         with PatchedHttp(api, self.data):
             self.assertRaises(api.APIMWException, req.submit)
+            pywikibot.warning.assert_called_with(
+                'API error internal_api_error_fake: Fake error message')
+            pywikibot.error.assert_called_with(
+                'You have no API read permissions. '
+                'Seems you are not logged in.')

     def test_API_error_encoding_ASCII(self):
         """Test a Page instance as parameter using ASCII chars."""
@@ -111,6 +109,11 @@
         self.assert_parameters = {'fake': ''}
         with PatchedHttp(api, self._dummy_request):
             self.assertRaises(api.APIMWException, req.submit)
+            pywikibot.warning.assert_called_with(
+                'API error internal_api_error_fake: Fake error message')
+            pywikibot.error.assert_called_with(
+                'Detected MediaWiki API exception internal_api_error_fake: '
+                'Fake error message\n[servedby: unittest]; raising')

     def test_API_error_encoding_Unicode(self):
         """Test a Page instance as parameter using non-ASCII chars."""
@@ -121,6 +124,11 @@
         self.assert_parameters = {'fake': ''}
         with PatchedHttp(api, self._dummy_request):
             self.assertRaises(api.APIMWException, req.submit)
+            pywikibot.warning.assert_called_with(
+                'API error internal_api_error_fake: Fake error message')
+            pywikibot.error.assert_called_with(
+                'Detected MediaWiki API exception internal_api_error_fake: '
+                'Fake error message\n[servedby: unittest]; raising')


 class TestApiFunctions(DefaultSiteTestCase):

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If33fcd52f16f832a020894f4975f1c060dd9f9b4
Gerrit-Change-Number: 631912
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to