Merge ~pkopylov/qa-regression-testing:testlib_assert_file_type into qa-regression-testing:master
Status: | Merged |
---|---|
Merged at revision: | 503c71149c028e840958d702aad5271b2f643018 |
Proposed branch: | ~pkopylov/qa-regression-testing:testlib_assert_file_type |
Merge into: | qa-regression-testing:master |
Diff against target: |
39 lines (+13/-5) 1 file modified
scripts/testlib.py (+13/-5) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Steve Beattie | Approve | ||
Alex Murray | Needs Fixing | ||
Review via email: mp+434935@code.launchpad.net |
Commit message
scripts/testlib.py: the function assertFileType() was improved in order to handle files that have two or more recognized file-types correctly
Description of the change
When I was running test-bzip2.py on ubuntu 16.04 I met the situation when the /usr/bin/file utility detected an unexpected file type for some file during the test. Actually, that compressed file had two types, but the mentioned utility output only the first one. However, the expected type was the second known type, so it was not printed at all.
Fortunately, the /usr/bin/file utility can output all recognized file's types, not only the first.
This commit changes the utility's command line adding two options: -k and -r, as a result, all recognized types will be output and if even one of them matches to expected then an assertion will be true.
Since the output of file will now include multiple lines, would it be better to explicitly iterate over each line and test them separately to find the match? That would make the code a bit easier to understand IMO rather than trying to include a newline as part of the regex to match.