Skip to content

Commit 4e42f7d

Browse files
author
Andy Landy
committed
fix tests
1 parent a709a59 commit 4e42f7d

2 files changed

Lines changed: 3 additions & 29 deletions

File tree

tests/dumps/test_main.argparse_code_wrong_args.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,6 @@ Traceback with variables (most recent call last):
2626
namespace = Namespace(arg=None)
2727
action = _StoreAction(option_strings=['--arg'], dest='arg', nargs=None, const=None, default=None, type=<class 'int'>, choices=None, help=None, metavar=None)
2828
File "...omitted for tests only.../argparse.py", line...omitted for tests only..., in _parse_known_args
29-
self.error(_('the following arguments are required: %s') %
30-
i = 1
31-
arg_string_pattern_parts = ['O', 'A']
32-
arg_strings_iter = list_iterator()
33-
arg_string = 'value'
34-
option_tuple = None
35-
pattern = 'A'
36-
consume_optional = <function ArgumentParser._parse_known_args.<locals>.consume_optional at 0x...omitted for tests only...>
37-
consume_positionals = <function ArgumentParser._parse_known_args.<locals>.consume_positionals at 0x...omitted for tests only...>
38-
max_option_string_index = 0
39-
next_option_string_index = 0
40-
stop_index = 1
41-
required_actions = ['--arg']
42-
action = _StoreAction(option_strings=['--arg'], dest='arg', nargs=None, const=None, default=None, type=<class 'int'>, choices=None, help=None, metavar=None)
43-
action_conflicts = {}
44-
arg_strings = ['--wrong', 'value']
45-
arg_strings_pattern = 'OA'
46-
extras = ['--wrong', 'value']
47-
namespace = Namespace(arg=None)
48-
option_string_indices = {0: (None, '--wrong', None)}
49-
positionals = []
50-
seen_actions = set()
51-
seen_non_default_actions = set()
52-
self = ArgumentParser(prog='code.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
53-
start_index = 1
54-
take_action = <function ArgumentParser._parse_known_args.<locals>.take_action at 0x...omitted for tests only...>
55-
File "...omitted for tests only.../argparse.py", line...omitted for tests only..., in error
56-
self.exit(2, _('%(prog)s: error: %(message)s/n') % args)
57-
self = ArgumentParser(prog='code.py', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
5829
message = 'the following arguments are required: --arg'
5930
args = {'prog': 'code.py', 'message': 'the following arguments are required: --arg'}
6031
File "...omitted for tests only.../argparse.py", line...omitted for tests only..., in exit

tests/test_main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def do_test_code_(main_argv: List[str], lines: List[str], code_argv: List[str],
144144
code_argv=code_argv,
145145
raises=raises
146146
)
147+
if out.startswith('usage:') and out.count('\n') > 37: # :)
148+
lines = out.split('\n')
149+
out = '\n'.join(lines[:27] + lines[-10:]) # argparse codes differs in py versions
147150
out = re.sub(r'\[([^-][^\s]+) \[[^\s]+ ...]]', r'[\1 ...]', out)
148151
out = re.sub(r']\s+', ']\n', out)
149152
out = out.replace('optional arguments', 'options')

0 commit comments

Comments
 (0)