jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/769418 )
Change subject: [tests] Provide generator script tests
......................................................................
[tests] Provide generator script tests
A new TestScriptGenerator script test class is introduced which
runs scripts with '-simulate -page:Foo -always'. This may be
expanded by different arguments and various responses later.
Change-Id: I59de76f371955b5154bd1a68a150b2ca936e80e7
---
M tests/script_tests.py
1 file changed, 52 insertions(+), 4 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index e66c465..2c2aef4 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -213,8 +213,11 @@
timeout = 5 if do_timeout else None
stdout, error = None, None
- if self._results and script_name in self._results:
- error = self._results[script_name]
+ if self._results:
+ if isinstance(self._results, dict):
+ error = self._results.get(script_name)
+ else:
+ error = self._results
if isinstance(error, tuple):
stdout, error = error
@@ -359,9 +362,9 @@
class TestScriptSimulate(DefaultSiteTestCase, PwbTestCase,
metaclass=TestScriptMeta):
- """Test cases for scripts.
+ """Test cases for running scripts with -siumlate.
- This class sets the'user' attribute on every test, thereby ensuring
+ This class sets the 'user' attribute on every test, thereby ensuring
that the test runner has a username for the default site, and so that
Site.login() is called in the test runner, which means that the scripts
run in pwb can automatically login using the saved cookies.
@@ -386,6 +389,51 @@
_timeout = auto_run_script_list
+class TestScriptGenerator(DefaultSiteTestCase, PwbTestCase,
+ metaclass=TestScriptMeta):
+
+ """Test cases for running scripts with a generator."""
+
+ login = True
+
+ _expected_failures = {
+ 'add_text',
+ 'archivebot',
+ 'category',
+ 'change_pagelang',
+ 'claimit',
+ 'commonscat',
+ 'data_ingestion',
+ 'delete',
+ 'djvutext',
+ 'download_dump',
+ 'harvest_template',
+ 'image',
+ 'interwiki',
+ 'listpages',
+ 'movepages',
+ 'newitem',
+ 'pagefromfile',
+ 'protect',
+ 'redirect',
+ 'replicate_wiki',
+ 'solve_disambiguation',
+ 'speedy_delete',
+ 'template',
+ 'templatecount',
+ 'transferbot',
+ 'weblinkchecker',
+ }
+
+ _allowed_failures = [
+ ]
+
+ _arguments = '-simulate -page:Foo -always'
+ _results = ("Working on 'Foo'", '1 pages read')
+ _skip_results = {}
+ _timeout = True
+
+
if __name__ == '__main__': # pragma: no cover
with suppress(SystemExit):
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/769418
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: I59de76f371955b5154bd1a68a150b2ca936e80e7
Gerrit-Change-Number: 769418
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]