jenkins-bot submitted this change.

View Change

Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
[fix] Fix TestSiteSysopWrite.test_protect_exception

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

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 change 1041667. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1e0b6f5e2ae49d7a643b5dacb13595fe5e6eb005
Gerrit-Change-Number: 1041667
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot