Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- F move verify_argument_parser scrubber to caller #185

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions approvaltests/approvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,7 @@ def verify_argument_parser(
options: Optional[Options] = None,
) -> None:
parser.formatter_class = lambda prog: argparse.HelpFormatter(prog, width=200)
options = options or Options()
scrubber = lambda t: t.replace("options:", "<optional header>:").replace(
"optional arguments:", "<optional header>:"
)
verify(
parser.format_help(),
options=options.with_scrubber(scrubber),
options=options,
)
5 changes: 4 additions & 1 deletion tests/test_find_stale_approved_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def execute_script(directory, log_file):


def test_create_argument_parser():
verify_argument_parser(create_argument_parser())
scrubber = lambda t: t.replace("options:", "<optional header>:").replace(
"optional arguments:", "<optional header>:"
)
verify_argument_parser(create_argument_parser(), options=Options().with_scrubber(scrubber))


def test_find_stale_approved_files():
Expand Down
10 changes: 6 additions & 4 deletions tests/test_verify_argument_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import argparse
import os

from approvaltests import verify_argument_parser
from tests.find_stale_approved_files import create_argument_parser
from approvaltests import verify_argument_parser, Options


def test_argument_parser():
Expand All @@ -13,4 +11,8 @@ def test_argument_parser():
parser.add_argument("1st_argument", help="1st argument help text")
parser.add_argument("--optional_argument", help="An Optional Argument help text")
parser.add_argument("long_argument", help=f"{'Very' * 100} Long message")
verify_argument_parser(parser)

scrubber = lambda t: t.replace("options:", "<optional header>:").replace(
"optional arguments:", "<optional header>:"
)
verify_argument_parser(parser, options=Options().with_scrubber(scrubber))
Loading