jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/838166 )
Change subject: [tests] Fix TestDeletionBotUser test
......................................................................
[tests] Fix TestDeletionBotUser test
use setUpClass/tearDownClass to reset the test page content
Change-Id: I1978352a485a118c81fcc8bb14682db2ead914b9
---
M tests/deletionbot_tests.py
1 file changed, 25 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py
index 37e981d..716ea80 100755
--- a/tests/deletionbot_tests.py
+++ b/tests/deletionbot_tests.py
@@ -56,19 +56,35 @@
write = True
+ @classmethod
+ def setUpClass(cls):
+ """Set up test class."""
+ super().setUpClass()
+ cls.page = pywikibot.Page(cls.site, 'User:Unicodesnowman/DeleteMark')
+ if not cls.page.exists():
+ cls.save_page() # pragma: no cover
+
+ @classmethod
+ def tearDownClass(cls):
+ """Tear down test class."""
+ cls.save_page()
+ super().tearDownClass()
+
+ @classmethod
+ def save_page(cls):
+ """Reset the test page content."""
+ cls.page.text = 'Pywikibot deletion test.'
+ cls.page.save('Pywikibot unit test', botflag=True)
+
def test_delete_mark(self):
"""Test marking User:Unicodesnowman/DeleteMark for
deletion."""
- site = self.get_site()
- p1 = pywikibot.Page(site, 'User:Unicodesnowman/DeleteMark')
- if not p1.exists():
- p1.text = 'foo'
- p1.save('unit test', botflag=True)
delete.main('-page:User:Unicodesnowman/DeleteMark', '-always',
'-summary=pywikibot unit test. Do NOT actually delete.')
- self.assertEqual(p1.get(force=True), '{{delete|1=pywikibot unit test. '
- 'Do NOT actually delete.}}\nfoo')
- p1.text = 'foo'
- p1.save('unit test', botflag=True)
+ text = self.page.get(force=True)
+ self.assertEqual(
+ text,
+ '{{delete|1=pywikibot unit test. Do NOT actually delete.}}\n'
+ 'Pywikibot deletion test.')
class TestDeletionBot(ScriptMainTestCase):
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/838166
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: I1978352a485a118c81fcc8bb14682db2ead914b9
Gerrit-Change-Number: 838166
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged