==================================================================== FAILURES ====================================================================
_________________________________________________________ test_apcustom_required_options _________________________________________________________
def test_apcustom_required_options():
# Make sure a 'required arguments' section shows when a flag is marked required
parser = Cmd2ArgumentParser()
parser.add_argument('--required_flag', required=True)
> assert 'required arguments' in parser.format_help()
E AssertionError: assert 'required arguments' in 'Usage: __main__.py --required_flag REQUIRED_FLAG [-h]\n\noptions:\n -h, --help show this help message and exit\n --required_flag REQUIRED_FLAG\n\n'
E + where 'Usage: __main__.py --required_flag REQUIRED_FLAG [-h]\n\noptions:\n -h, --help show this help message and exit\n --required_flag REQUIRED_FLAG\n\n' = <bound method Cmd2ArgumentParser.format_help of Cmd2ArgumentParser(prog='__main__.py', usage=None, description=None, formatter_class=<class 'cmd2.argparse_custom.Cmd2HelpFormatter'>, conflict_handler='error', add_help=True)>()
E + where <bound method Cmd2ArgumentParser.format_help of Cmd2ArgumentParser(prog='__main__.py', usage=None, description=None, formatter_class=<class 'cmd2.argparse_custom.Cmd2HelpFormatter'>, conflict_handler='error', add_help=True)> = Cmd2ArgumentParser(prog='__main__.py', usage=None, description=None, formatter_class=<class 'cmd2.argparse_custom.Cmd2HelpFormatter'>, conflict_handler='error', add_help=True).format_help
tests/test_argparse_custom.py:246: AssertionError
__________________________________________________________ test_help_with_no_docstring ___________________________________________________________
capsys = <_pytest.capture.CaptureFixture object at 0x7f51a662fd30>
def test_help_with_no_docstring(capsys):
app = HelpNoDocstringApp()
app.onecmd_plus_hooks('greet -h')
out, err = capsys.readouterr()
assert err == ''
> assert (
out
== """usage: greet [-h] [-s]
optional arguments:
-h, --help show this help message and exit
-s, --shout N00B EMULATION MODE
"""
)
E AssertionError: assert 'usage: greet...LATION MODE\n' == 'usage: greet...LATION MODE\n'
E usage: greet [-h] [-s]
E
E - optional arguments:
E + options:
E -h, --help show this help message and exit
E -s, --shout N00B EMULATION MODE
tests/test_cmd2.py:1384: AssertionError
_____________________________________________________________ test_base_help_history _____________________________________________________________
base_app = <cmd2.cmd2.Cmd object at 0x7f51a55a6050>
def test_base_help_history(base_app):
out, err = run_cmd(base_app, 'help history')
> assert out == normalize(HELP_HISTORY)
E AssertionError: assert ['Usage: hist...nds', '', ...] == ['Usage: hist...nds', '', ...]
E At index 13 diff: 'options:' != 'optional arguments:'
E Use -v to get the full diff
tests/test_history.py:779: AssertionError
_____________________________________________________ test_transcript[from_cmdloop.txt-True] _____________________________________________________
request = <FixtureRequest for <Function test_transcript[from_cmdloop.txt-True]>>
capsys = <_pytest.capture.CaptureFixture object at 0x7f51a6711a80>, filename = 'from_cmdloop.txt', feedback_to_output = True
@pytest.mark.parametrize(
'filename,feedback_to_output',
[
('bol_eol.txt', False),
('characterclass.txt', False),
('dotstar.txt', False),
('extension_notation.txt', False),
('from_cmdloop.txt', True),
('multiline_no_regex.txt', False),
('multiline_regex.txt', False),
('no_output.txt', False),
('no_output_last.txt', False),
('regex_set.txt', False),
('singleslash.txt', False),
('slashes_escaped.txt', False),
('slashslash.txt', False),
('spaces.txt', False),
('word_boundaries.txt', False),
],
)
def test_transcript(request, capsys, filename, feedback_to_output):
# Get location of the transcript
test_dir = os.path.dirname(request.module.__file__)
transcript_file = os.path.join(test_dir, 'transcripts', filename)
# Need to patch sys.argv so cmd2 doesn't think it was called with
# arguments equal to the py.test args
testargs = ['prog', '-t', transcript_file]
with mock.patch.object(sys, 'argv', testargs):
# Create a cmd2.Cmd() instance and make sure basic settings are
# like we want for test
app = CmdLineApp()
app.feedback_to_output = feedback_to_output
# Run the command loop
sys_exit_code = app.cmdloop()
> assert sys_exit_code == 0
E assert 1 == 0
tests/test_transcript.py:149: AssertionError
-------------------------------------------------------------- Captured stdout call --------------------------------------------------------------
============================= cmd2 transcript test =============================
platform linux -- Python 3.10.0, cmd2-2.1.1.dev0+g54a7752d.d20210614, readline-GNU
cwd: /tmp/cmd2
cmd2 app: /tmp/cmd2/.venv/lib/python3.10/site-packages/pytest/__main__.py
collected 1 transcript
-------------------------------------------------------------- Captured stderr call --------------------------------------------------------------
File /tmp/cmd2/tests/transcripts/from_cmdloop.txt, line 15
Command was:
help say
Expected:
usage:\ speak\ \[\-h\]\ \[\-p\]\ \[\-s\]\ \[\-r\ REPEAT\] *\
\
Repeats\ what\ you\ tell\ me\ to\. *\
\
optional\ arguments: *\
\ \ \-h,\ \-\-help\ \ \ \ \ \ \ \ \ \ \ \ show\ this\ help\ message\ and\ exit *\
\ \ \-p,\ \-\-piglatin\ \ \ \ \ \ \ \ atinLay *\
\ \ \-s,\ \-\-shout\ \ \ \ \ \ \ \ \ \ \ N00B\ EMULATION\ MODE *\
\ \ \-r\ REPEAT,\ \-\-repeat\ REPEAT *\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ output\ \[n\]\ times\
Got:
usage: speak [-h] [-p] [-s] [-r REPEAT]
Repeats what you tell me to.
options:
-h, --help show this help message and exit
-p, --piglatin atinLay
-s, --shout N00B EMULATION MODE
-r REPEAT, --repeat REPEAT
output [n] times
----------------------------------------------------------------------
Ran 1 test in 0.005s
FAILED (failures=1)
----------- coverage: platform linux, python 3.10.0-beta-2 -----------
Name Stmts Miss Cover
--------------------------------------------------
cmd2/__init__.py 26 1 96.2%
cmd2/ansi.py 160 0 100.0%
cmd2/argparse_completer.py 316 1 99.7%
cmd2/argparse_custom.py 330 32 90.3%
cmd2/clipboard.py 14 2 85.7%
cmd2/cmd2.py 2185 224 89.7%
cmd2/command_definition.py 55 36 34.5%
cmd2/constants.py 26 0 100.0%
cmd2/decorators.py 115 3 97.4%
cmd2/exceptions.py 24 0 100.0%
cmd2/history.py 134 0 100.0%
cmd2/parsing.py 291 0 100.0%
cmd2/plugin.py 19 0 100.0%
cmd2/py_bridge.py 41 0 100.0%
cmd2/rl_utils.py 41 17 58.5%
cmd2/table_creator.py 418 0 100.0%
cmd2/transcript.py 114 8 93.0%
cmd2/utils.py 433 17 96.1%
--------------------------------------------------
TOTAL 4742 341 92.8%
Coverage HTML written to dir htmlcov
============================================================ short test summary info =============================================================
FAILED tests/test_argparse_custom.py::test_apcustom_required_options - AssertionError: assert 'required arguments' in 'Usage: __main__.py --req...
FAILED tests/test_cmd2.py::test_help_with_no_docstring - AssertionError: assert 'usage: greet...LATION MODE\n' == 'usage: greet...LATION MODE\n'
FAILED tests/test_history.py::test_base_help_history - AssertionError: assert ['Usage: hist...nds', '', ...] == ['Usage: hist...nds', '', ...]
FAILED tests/test_transcript.py::test_transcript[from_cmdloop.txt-True] - assert 1 == 0
It seems that a few
--helplabels have changed in Python 3.10 and they're breaking the test expectations.Tested with git 54a7752, using Python 3.10.0b2.
==================================================================== FAILURES ==================================================================== _________________________________________________________ test_apcustom_required_options _________________________________________________________ def test_apcustom_required_options(): # Make sure a 'required arguments' section shows when a flag is marked required parser = Cmd2ArgumentParser() parser.add_argument('--required_flag', required=True) > assert 'required arguments' in parser.format_help() E AssertionError: assert 'required arguments' in 'Usage: __main__.py --required_flag REQUIRED_FLAG [-h]\n\noptions:\n -h, --help show this help message and exit\n --required_flag REQUIRED_FLAG\n\n' E + where 'Usage: __main__.py --required_flag REQUIRED_FLAG [-h]\n\noptions:\n -h, --help show this help message and exit\n --required_flag REQUIRED_FLAG\n\n' = <bound method Cmd2ArgumentParser.format_help of Cmd2ArgumentParser(prog='__main__.py', usage=None, description=None, formatter_class=<class 'cmd2.argparse_custom.Cmd2HelpFormatter'>, conflict_handler='error', add_help=True)>() E + where <bound method Cmd2ArgumentParser.format_help of Cmd2ArgumentParser(prog='__main__.py', usage=None, description=None, formatter_class=<class 'cmd2.argparse_custom.Cmd2HelpFormatter'>, conflict_handler='error', add_help=True)> = Cmd2ArgumentParser(prog='__main__.py', usage=None, description=None, formatter_class=<class 'cmd2.argparse_custom.Cmd2HelpFormatter'>, conflict_handler='error', add_help=True).format_help tests/test_argparse_custom.py:246: AssertionError __________________________________________________________ test_help_with_no_docstring ___________________________________________________________ capsys = <_pytest.capture.CaptureFixture object at 0x7f51a662fd30> def test_help_with_no_docstring(capsys): app = HelpNoDocstringApp() app.onecmd_plus_hooks('greet -h') out, err = capsys.readouterr() assert err == '' > assert ( out == """usage: greet [-h] [-s] optional arguments: -h, --help show this help message and exit -s, --shout N00B EMULATION MODE """ ) E AssertionError: assert 'usage: greet...LATION MODE\n' == 'usage: greet...LATION MODE\n' E usage: greet [-h] [-s] E E - optional arguments: E + options: E -h, --help show this help message and exit E -s, --shout N00B EMULATION MODE tests/test_cmd2.py:1384: AssertionError _____________________________________________________________ test_base_help_history _____________________________________________________________ base_app = <cmd2.cmd2.Cmd object at 0x7f51a55a6050> def test_base_help_history(base_app): out, err = run_cmd(base_app, 'help history') > assert out == normalize(HELP_HISTORY) E AssertionError: assert ['Usage: hist...nds', '', ...] == ['Usage: hist...nds', '', ...] E At index 13 diff: 'options:' != 'optional arguments:' E Use -v to get the full diff tests/test_history.py:779: AssertionError _____________________________________________________ test_transcript[from_cmdloop.txt-True] _____________________________________________________ request = <FixtureRequest for <Function test_transcript[from_cmdloop.txt-True]>> capsys = <_pytest.capture.CaptureFixture object at 0x7f51a6711a80>, filename = 'from_cmdloop.txt', feedback_to_output = True @pytest.mark.parametrize( 'filename,feedback_to_output', [ ('bol_eol.txt', False), ('characterclass.txt', False), ('dotstar.txt', False), ('extension_notation.txt', False), ('from_cmdloop.txt', True), ('multiline_no_regex.txt', False), ('multiline_regex.txt', False), ('no_output.txt', False), ('no_output_last.txt', False), ('regex_set.txt', False), ('singleslash.txt', False), ('slashes_escaped.txt', False), ('slashslash.txt', False), ('spaces.txt', False), ('word_boundaries.txt', False), ], ) def test_transcript(request, capsys, filename, feedback_to_output): # Get location of the transcript test_dir = os.path.dirname(request.module.__file__) transcript_file = os.path.join(test_dir, 'transcripts', filename) # Need to patch sys.argv so cmd2 doesn't think it was called with # arguments equal to the py.test args testargs = ['prog', '-t', transcript_file] with mock.patch.object(sys, 'argv', testargs): # Create a cmd2.Cmd() instance and make sure basic settings are # like we want for test app = CmdLineApp() app.feedback_to_output = feedback_to_output # Run the command loop sys_exit_code = app.cmdloop() > assert sys_exit_code == 0 E assert 1 == 0 tests/test_transcript.py:149: AssertionError -------------------------------------------------------------- Captured stdout call -------------------------------------------------------------- ============================= cmd2 transcript test ============================= platform linux -- Python 3.10.0, cmd2-2.1.1.dev0+g54a7752d.d20210614, readline-GNU cwd: /tmp/cmd2 cmd2 app: /tmp/cmd2/.venv/lib/python3.10/site-packages/pytest/__main__.py collected 1 transcript -------------------------------------------------------------- Captured stderr call -------------------------------------------------------------- File /tmp/cmd2/tests/transcripts/from_cmdloop.txt, line 15 Command was: help say Expected: usage:\ speak\ \[\-h\]\ \[\-p\]\ \[\-s\]\ \[\-r\ REPEAT\] *\ \ Repeats\ what\ you\ tell\ me\ to\. *\ \ optional\ arguments: *\ \ \ \-h,\ \-\-help\ \ \ \ \ \ \ \ \ \ \ \ show\ this\ help\ message\ and\ exit *\ \ \ \-p,\ \-\-piglatin\ \ \ \ \ \ \ \ atinLay *\ \ \ \-s,\ \-\-shout\ \ \ \ \ \ \ \ \ \ \ N00B\ EMULATION\ MODE *\ \ \ \-r\ REPEAT,\ \-\-repeat\ REPEAT *\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ output\ \[n\]\ times\ Got: usage: speak [-h] [-p] [-s] [-r REPEAT] Repeats what you tell me to. options: -h, --help show this help message and exit -p, --piglatin atinLay -s, --shout N00B EMULATION MODE -r REPEAT, --repeat REPEAT output [n] times ---------------------------------------------------------------------- Ran 1 test in 0.005s FAILED (failures=1) ----------- coverage: platform linux, python 3.10.0-beta-2 ----------- Name Stmts Miss Cover -------------------------------------------------- cmd2/__init__.py 26 1 96.2% cmd2/ansi.py 160 0 100.0% cmd2/argparse_completer.py 316 1 99.7% cmd2/argparse_custom.py 330 32 90.3% cmd2/clipboard.py 14 2 85.7% cmd2/cmd2.py 2185 224 89.7% cmd2/command_definition.py 55 36 34.5% cmd2/constants.py 26 0 100.0% cmd2/decorators.py 115 3 97.4% cmd2/exceptions.py 24 0 100.0% cmd2/history.py 134 0 100.0% cmd2/parsing.py 291 0 100.0% cmd2/plugin.py 19 0 100.0% cmd2/py_bridge.py 41 0 100.0% cmd2/rl_utils.py 41 17 58.5% cmd2/table_creator.py 418 0 100.0% cmd2/transcript.py 114 8 93.0% cmd2/utils.py 433 17 96.1% -------------------------------------------------- TOTAL 4742 341 92.8% Coverage HTML written to dir htmlcov ============================================================ short test summary info ============================================================= FAILED tests/test_argparse_custom.py::test_apcustom_required_options - AssertionError: assert 'required arguments' in 'Usage: __main__.py --req... FAILED tests/test_cmd2.py::test_help_with_no_docstring - AssertionError: assert 'usage: greet...LATION MODE\n' == 'usage: greet...LATION MODE\n' FAILED tests/test_history.py::test_base_help_history - AssertionError: assert ['Usage: hist...nds', '', ...] == ['Usage: hist...nds', '', ...] FAILED tests/test_transcript.py::test_transcript[from_cmdloop.txt-True] - assert 1 == 0