Skip to content
Snippets Groups Projects

Make command-line tests a bit more resilient

1 unresolved thread

We now match the command line output per section, in a fuzzier way than before.

Test Plan

tox tests updated


Migrated from D4626 (view on Phabricator)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
31 in_section = False
32 for line in cli_output.splitlines():
33 if not line:
34 continue
35
36 if in_section:
37 if not line.startswith(" "):
38 break
39 else:
40 if line.startswith(section):
41 in_section = True
42
43 if in_section:
44 result.append(line)
45
46 return result
  • That's equivalent to this code: re.match(f"^{re.escape(section)}.*?\n\n", cli_output, re.MULTILINE).group(0).splitlines() (assuming there is a match), right?

    The regexp is easier to read IMO; but either is fine.

  • and with re.DOTALL *

  • Author Maintainer

    Well the code only keeps indented lines as section contents, so it's a bit more subtle than the regexp. I've done this because the Usage section has an empty line between the header and the contents, which breaks that regexp approach.

  • Please register or sign in to reply
  • Merge request was accepted

  • Antoine R. Dumont approved this merge request

    approved this merge request

  • Author Maintainer

    Merge request was merged

  • Please register or sign in to reply
    Loading