Skip to content

Commit

Permalink
- F move verify_argument_parser scrubber to caller
Browse files Browse the repository at this point in the history
  • Loading branch information
JayBazuzi committed Nov 12, 2024
1 parent ae7b1ff commit cc0423b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
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
7 changes: 6 additions & 1 deletion tests/test_verify_argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from approvaltests import verify_argument_parser
from tests.find_stale_approved_files import create_argument_parser
from approvaltests.core.options import Options


def test_argument_parser():
Expand All @@ -13,4 +14,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))

0 comments on commit cc0423b

Please sign in to comment.