jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] script tests: Expect stdout text ......................................................................
[FIX] script tests: Expect stdout text
This adds support for text in stdout. Scripts either output parts of it or nothing.
Bug: T96615 Change-Id: Ia454447bf55cb9c05da1204a26fe49004154cd14 --- M tests/script_tests.py 1 file changed, 16 insertions(+), 7 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py index 5731006..53bfa4e 100644 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -17,6 +17,9 @@ from tests.aspects import unittest, DefaultSiteTestCase, MetaTestCaseClass, PwbTestCase from tests.utils import allowed_failure, execute_pwb
+if sys.version_info[0] > 2: + basestring = (str, ) + scripts_path = os.path.join(_root_dir, 'scripts')
# These dependencies are not always the package name which is in setup.py. @@ -139,9 +142,10 @@ 'pagefromfile': 'Please enter the file name', 'replace': 'Press Enter to use this automatic message', 'script_wui': 'Pre-loading all relevant page contents', - 'shell': 'Welcome to the', + 'shell': ('>>> ', 'Welcome to the'), 'spamremove': 'No spam site specified', 'transferbot': 'Target site not different from source site', # Bug 68662 + 'unusedfiles': ('Working on', None), 'version': 'unicode test: ', 'watchlist': 'Retrieving watchlist',
@@ -231,7 +235,12 @@
if expected_results and script_name in expected_results: error = expected_results[script_name] + if isinstance(error, basestring): + stdout = None + else: + stdout, error = error else: + stdout = None error = None
result = execute_pwb(cmd, data_in, timeout=timeout, error=error) @@ -284,13 +293,13 @@ if 'Global arguments available for all' not in result['stdout']: # Specifically look for deprecated self.assertNotIn('deprecated', result['stdout'].lower()) - # But also complain if there is any stdout - # but ignore shell.py emiting its '>>> ' prompt. - if ((script_name == 'shell' and - set(result['stdout']).issubset(set('> \n'))) or - result['stdout'] == ''): + if result['stdout'] == '': result['stdout'] = None - self.assertIsNone(result['stdout']) + # But also complain if there is any stdout + if stdout is not None and result['stdout'] is not None: + self.assertIn(stdout, result['stdout']) + else: + self.assertIsNone(result['stdout'])
self.assertIn(result['exit_code'], exit_codes)
pywikibot-commits@lists.wikimedia.org