Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1074377?usp=email )

Change subject: [tests] run editfailure tests with Pywikibot-oauth
......................................................................

[tests] run editfailure tests with Pywikibot-oauth

Also skip some tests with Pywikibot-test sysop account

Bug: T375258
Change-Id: Ied4d55ea8cee5014074a1902ebcae99232407a98
---
M .github/workflows/oauth_tests-ci.yml
M tests/edit_failure_tests.py
2 files changed, 38 insertions(+), 30 deletions(-)

Approvals:
  Xqt: Verified; Looks good to me, approved




diff --git a/.github/workflows/oauth_tests-ci.yml 
b/.github/workflows/oauth_tests-ci.yml
index f57afdc..2a25b00 100644
--- a/.github/workflows/oauth_tests-ci.yml
+++ b/.github/workflows/oauth_tests-ci.yml
@@ -1,5 +1,5 @@
 name: Oauth CI
-# Run login tests using OAuth
+# Run login tests using OAuth and non-sysop tests on test wiki

 on:
   push:
@@ -21,7 +21,6 @@

     strategy:
       fail-fast: false
-      max-parallel: 8

       matrix:
         python-version: [ "pypy3.7", "pypy3.10", "3.7", "3.8", "3.9", "3.10", 
"3.11", "3.12", "3.13.0-alpha - 3.13.0", "3.14-dev" ]
@@ -103,7 +102,7 @@
       env:
         PYWIKIBOT_TEST_WRITE: 1
         PYWIKIBOT_TEST_OAUTH: ${{ secrets[format('{0}', 
steps.token.outputs.uppercase)] }}
-        PYWIKIBOT_TEST_MODULES: file,oauth
+        PYWIKIBOT_TEST_MODULES: edit_failure,file,oauth
       run: |
         python pwb.py version
         coverage run -m unittest -vv
diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py
index 8008ebe..7b80736 100755
--- a/tests/edit_failure_tests.py
+++ b/tests/edit_failure_tests.py
@@ -40,33 +40,6 @@
     family = 'wikipedia'
     code = 'test'

-    def test_protected(self):
-        """Test that protected titles raise the appropriate exception."""
-        if self.site.has_group('sysop'):
-            self.skipTest(
-                'Testing failure of edit protected with a sysop account')
-        page = pywikibot.Page(self.site, 'Wikipedia:Create a new page')
-        with self.assertRaises(LockedPageError):
-            page.save()
-
-    def test_spam(self):
-        """Test that spam in content raise the appropriate exception."""
-        page = pywikibot.Page(self.site, 'Wikipedia:Sandbox')
-        page.text = 'http://badsite.com'
-        with skipping(OtherPageSaveError), self.assertRaisesRegex(
-                SpamblacklistError, 'badsite.com'):
-            page.save()
-
-    def test_titleblacklist(self):
-        """Test that title blacklist raise the appropriate exception."""
-        user = pywikibot.User(self.site, self.site.user())
-        if 'sysop' in user.groups():
-            self.skipTest(f'{user} is member of the sysop group')
-
-        page = pywikibot.Page(self.site, 'User:UpsandDowns1234/Blacklisttest')
-        with self.assertRaises(TitleblacklistError):
-            page.save()
-
     def test_nobots(self):
         """Test that {{nobots}} raise the appropriate exception."""
         page = pywikibot.Page(self.site, 'User:John Vandenberg/nobots')
@@ -104,6 +77,42 @@
             page.save(recreate=False)


+class TestNonSysopSaveFailure(TestCase):
+
+    """Tests for edits which should fail to save for non-sysop accounts."""
+
+    write = True
+    family = 'wikipedia'
+    code = 'test'
+
+    @classmethod
+    def setUpClass(cls):
+        """Skip tests for sysop accounts."""
+        super().setUpClass()
+        if cls.site.has_group('sysop'):
+            raise unittest.SkipTest('Testing failure with a sysop account')
+
+    def test_protected(self):
+        """Test that protected titles raise the appropriate exception."""
+        page = pywikibot.Page(self.site, 'Wikipedia:Create a new page')
+        with self.assertRaises(LockedPageError):
+            page.save()
+
+    def test_spam(self):
+        """Test that spam in content raise the appropriate exception."""
+        page = pywikibot.Page(self.site, 'Wikipedia:Sandbox')
+        page.text = 'http://badsite.com'
+        with skipping(OtherPageSaveError), self.assertRaisesRegex(
+                SpamblacklistError, 'badsite.com'):
+            page.save()
+
+    def test_titleblacklist(self):
+        """Test that title blacklist raise the appropriate exception."""
+        page = pywikibot.Page(self.site, 'User:UpsandDowns1234/Blacklisttest')
+        with self.assertRaises(TitleblacklistError):
+            page.save()
+
+
 class TestActionFailure(TestCase):

     """Test cases for actions which should fail to save."""

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1074377?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: Ied4d55ea8cee5014074a1902ebcae99232407a98
Gerrit-Change-Number: 1074377
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org
To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org

Reply via email to