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

Change subject: [tests] OAuthEditTest.test_edit may fail with EditConflictError
......................................................................

[tests] OAuthEditTest.test_edit may fail with EditConflictError

Just test this case.

Change-Id: I09ace300dded8f94ee1c55ce1c08b8e99618c355
---
M tests/oauth_tests.py
1 file changed, 12 insertions(+), 8 deletions(-)

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




diff --git a/tests/oauth_tests.py b/tests/oauth_tests.py
index 836b91a..6a7cc5e 100755
--- a/tests/oauth_tests.py
+++ b/tests/oauth_tests.py
@@ -13,6 +13,7 @@

 import pywikibot
 from pywikibot import config
+from pywikibot.exceptions import EditConflictError
 from pywikibot.login import OauthLoginManager
 from tests.aspects import (
     DefaultSiteTestCase,
@@ -74,15 +75,18 @@
         """Test editing to a page."""
         self.site.login()
         self.assertTrue(self.site.logged_in())
+        title = f'User:{self.site.username()}/edit test'
         ts = str(time.time())
-        p = pywikibot.Page(self.site,
-                           f'User:{self.site.username()}/edit test')
-        p.site.editpage(p, appendtext=ts)
-        revision_id = p.latest_revision_id
-        p = pywikibot.Page(self.site,
-                           f'User:{self.site.username()}/edit test')
-        self.assertEqual(revision_id, p.latest_revision_id)
-        self.assertTrue(p.text.endswith(ts))
+        p = pywikibot.Page(self.site, title)
+        try:
+            p.site.editpage(p, appendtext=ts)
+        except EditConflictError as e:
+            self.assertEqual(e.page, p)
+        else:
+            revision_id = p.latest_revision_id
+            p = pywikibot.Page(self.site, title)
+            self.assertEqual(revision_id, p.latest_revision_id)
+            self.assertTrue(p.text.endswith(ts))

 
 class TestOauthLoginManger(DefaultSiteTestCase, OAuthSiteTestCase):

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1035891?usp=email
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: I09ace300dded8f94ee1c55ce1c08b8e99618c355
Gerrit-Change-Number: 1035891
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]
To unsubscribe send an email to [email protected]

Reply via email to