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

Change subject: [fix] Fix TestSiteSysopWrite.test_protect_exception
......................................................................

[fix] Fix TestSiteSysopWrite.test_protect_exception

Bug: T367185
Change-Id: I1e0b6f5e2ae49d7a643b5dacb13595fe5e6eb005
---
M tests/site_tests.py
1 file changed, 13 insertions(+), 7 deletions(-)

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




diff --git a/tests/site_tests.py b/tests/site_tests.py
index 7dfa510..f613729 100755
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -18,6 +18,7 @@
 import pywikibot
 from pywikibot import config
 from pywikibot.exceptions import (
+    APIError,
     IsNotRedirectPageError,
     NoPageError,
     PageInUseError,
@@ -620,13 +621,18 @@
     def test_protect_exception(self):
         """Test that site.protect() throws an exception for invalid args."""
         site = self.get_site()
-        p1 = pywikibot.Page(site, 'User:Unicodesnowman/ProtectTest')
-        with self.assertRaises(AssertionError):
-            site.protect(protections={'anInvalidValue': 'sysop'},
-                         page=p1, reason='Pywikibot unit test')
-        with self.assertRaises(AssertionError):
-            site.protect(protections={'edit': 'anInvalidValue'},
-                         page=p1, reason='Pywikibot unit test')
+        page = pywikibot.Page(site, 'User:Unicodesnowman/ProtectTest')
+
+        with self.subTest(test='anInvalidType'), \
+             self.assertRaisesRegex(APIError,
+                                    'Invalid protection type "anInvalidType"'):
+            site.protect(protections={'anInvalidType': 'sysop'},
+                         page=page, reason='Pywikibot unit test')
+
+        with self.subTest(test='anInvalidLevel'), \
+             self.assertRaises(AssertionError):
+            site.protect(protections={'edit': 'anInvalidLevel'},
+                         page=page, reason='Pywikibot unit test')

     def test_delete(self):
         """Test the site.delete() and site.undelete() methods."""

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1041667?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: I1e0b6f5e2ae49d7a643b5dacb13595fe5e6eb005
Gerrit-Change-Number: 1041667
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[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