tools: Update python "help" tests to cope with "more" oddities
PATCH 1/1 tools: Update python "help" tests to cope with "more" oddities
In some cases when "more" is told to page a given file it will prepend the output with:
::::::::::::::
/PATH/TO/THE/FILE
::::::::::::::
And when this happens the output will not match the expected length. Further, if we use a different pager we will instead fail the coverage tests as we will not have 100% coverage. Update the help test to remove the string in question.
---
I see this behavior when running the tests via Jenkins in my container, but not when run manually in my container. As implied above, I tried switching to less via the env, which causes these tests to pass but then the coverage tests fail as we will not have coverage of the line about "if not pager" and thus not have 100% coverage.
--- tools/binman/ftest.py | 5 ++++- tools/buildman/func_test.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
tools/binman/ftest.py +4 -1
@@ -290,7 +290,10 @@ class TestFunctional(unittest.TestCase): """Test that the full help is displayed with -H""" result = self._RunBinman('-H') help_file = os.path.join(self._binman_dir, 'README') - self.assertEqual(len(result.stdout), os.path.getsize(help_file)) + # Remove possible extraneous strings + extra = '::::::::::::::\n' + help_file + '\n::::::::::::::\n' + gothelp = result.stdout.replace(extra, '') + self.assertEqual(len(gothelp), os.path.getsize(help_file)) self.assertEqual(0, len(result.stderr)) self.assertEqual(0, result.return_code)
tools/buildman/func_test.py +4 -1
@@ -231,7 +231,10 @@ class TestFunctional(unittest.TestCase): command.test_result = None result = self._RunBuildman('-H') help_file = os.path.join(self._buildman_dir, 'README') - self.assertEqual(len(result.stdout), os.path.getsize(help_file)) + # Remove possible extraneous strings + extra = '::::::::::::::\n' + help_file + '\n::::::::::::::\n' + gothelp = result.stdout.replace(extra, '') + self.assertEqual(len(gothelp), os.path.getsize(help_file)) self.assertEqual(0, len(result.stderr)) self.assertEqual(0, result.return_code)
Signature · 1 line
2.7.4
PATCH 1/1 tools: Update python "help" tests to cope with "more" oddities
Quoted 19 lines · Tom Rini
In some cases when "more" is told to page a given file it will prepend the output with:
::::::::::::::
/PATH/TO/THE/FILE
::::::::::::::And when this happens the output will not match the expected length. Further, if we use a different pager we will instead fail the coverage tests as we will not have 100% coverage. Update the help test to remove the string in question.
Cc Simon Glass <[email protected]>Signed-off-by Tom Rini <[email protected]>---
I see this behavior when running the tests via Jenkins in my container, but not when run manually in my container. As implied above, I tried switching to less via the env, which causes these tests to pass but then the coverage tests fail as we will not have coverage of the line about "if not pager" and thus not have 100% coverage.
Quoted 4 lines
--- tools/binman/ftest.py | 5 ++++- tools/buildman/func_test.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)