From 076c9ebea10fba2a978d19057caccab9e8862ab4 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sun, 31 Jan 2021 23:13:27 -0500 Subject: Attempt to fix remaining black failures --- tests/conftest.py | 2 +- tests/test_argparse.py | 9 ++++- tests/test_argparse_custom.py | 10 ++++- tests/test_cmd2.py | 7 ++-- tests/test_history.py | 14 ++++++- tests/test_parsing.py | 90 ++++++++++++++++++++++++++++++++++++++----- 6 files changed, 113 insertions(+), 19 deletions(-) (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index 3fda7817..835739a7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -124,7 +124,7 @@ timing: False # Report execution times def normalize(block): - """ Normalize a block of text to perform comparison. + """Normalize a block of text to perform comparison. Strip newlines from the very beginning and very end Then split into separate lines and strip trailing whitespace from each line. diff --git a/tests/test_argparse.py b/tests/test_argparse.py index b28f722b..72f28abb 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -450,7 +450,14 @@ def test_pytest_mock_invalid(mocker): app = ArgparseApp() -@pytest.mark.parametrize('spec_param', [{'spec': True}, {'spec_set': True}, {'autospec': True},]) +@pytest.mark.parametrize( + 'spec_param', + [ + {'spec': True}, + {'spec_set': True}, + {'autospec': True}, + ], +) def test_pytest_mock_valid(mocker, spec_param): mocker.patch.object(ArgparseApp, 'namespace_provider', **spec_param) app = ArgparseApp() diff --git a/tests/test_argparse_custom.py b/tests/test_argparse_custom.py index dcac8a4f..86521f61 100644 --- a/tests/test_argparse_custom.py +++ b/tests/test_argparse_custom.py @@ -132,7 +132,15 @@ def test_apcustom_nargs_range_validation(cust_app): assert not err -@pytest.mark.parametrize('nargs_tuple', [(), ('f', 5), (5, 'f'), (1, 2, 3),]) +@pytest.mark.parametrize( + 'nargs_tuple', + [ + (), + ('f', 5), + (5, 'f'), + (1, 2, 3), + ], +) def test_apcustom_narg_invalid_tuples(nargs_tuple): with pytest.raises(ValueError) as excinfo: parser = Cmd2ArgumentParser() diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index aeb23c0c..ca88cf99 100755 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -2273,10 +2273,9 @@ class ReplWithExitCode(cmd2.Cmd): def do_exit(self, arg_list) -> bool: """Exit the application with an optional exit code. -Usage: exit [exit_code] - Where: - * exit_code - integer exit code to return to the shell -""" + Usage: exit [exit_code] + Where: + * exit_code - integer exit code to return to the shell""" # If an argument was provided if arg_list: try: diff --git a/tests/test_history.py b/tests/test_history.py index f687768e..ec05fb19 100755 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -284,7 +284,12 @@ def histitem(): from cmd2.parsing import Statement from cmd2.history import HistoryItem - statement = Statement('history', raw='help history', command='help', arg_list=['history'],) + statement = Statement( + 'history', + raw='help history', + command='help', + arg_list=['history'], + ) histitem = HistoryItem(statement, 1) return histitem @@ -341,7 +346,12 @@ def test_history_item_instantiate(): from cmd2.parsing import Statement from cmd2.history import HistoryItem - statement = Statement('history', raw='help history', command='help', arg_list=['history'],) + statement = Statement( + 'history', + raw='help history', + command='help', + arg_list=['history'], + ) with pytest.raises(TypeError): _ = HistoryItem() with pytest.raises(TypeError): diff --git a/tests/test_parsing.py b/tests/test_parsing.py index c40547da..291b0f55 100755 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -130,7 +130,14 @@ def test_command_and_args(parser, tokens, command, args): assert args == parsed_args -@pytest.mark.parametrize('line', ['plainword', '"one word"', "'one word'",]) +@pytest.mark.parametrize( + 'line', + [ + 'plainword', + '"one word"', + "'one word'", + ], +) def test_parse_single_word(parser, line): statement = parser.parse(line) assert statement.command == line @@ -149,7 +156,13 @@ def test_parse_single_word(parser, line): @pytest.mark.parametrize( - 'line,terminator', [('termbare;', ';'), ('termbare ;', ';'), ('termbare&', '&'), ('termbare &', '&'),] + 'line,terminator', + [ + ('termbare;', ';'), + ('termbare ;', ';'), + ('termbare&', '&'), + ('termbare &', '&'), + ], ) def test_parse_word_plus_terminator(parser, line, terminator): statement = parser.parse(line) @@ -163,7 +176,12 @@ def test_parse_word_plus_terminator(parser, line, terminator): @pytest.mark.parametrize( 'line,terminator', - [('termbare; suffx', ';'), ('termbare ;suffx', ';'), ('termbare& suffx', '&'), ('termbare &suffx', '&'),], + [ + ('termbare; suffx', ';'), + ('termbare ;suffx', ';'), + ('termbare& suffx', '&'), + ('termbare &suffx', '&'), + ], ) def test_parse_suffix_after_terminator(parser, line, terminator): statement = parser.parse(line) @@ -228,7 +246,13 @@ def test_parse_embedded_comment_char(parser): assert statement.arg_list == statement.argv[1:] -@pytest.mark.parametrize('line', ['simple | piped', 'simple|piped',]) +@pytest.mark.parametrize( + 'line', + [ + 'simple | piped', + 'simple|piped', + ], +) def test_parse_simple_pipe(parser, line): statement = parser.parse(line) assert statement.command == 'simple' @@ -265,7 +289,13 @@ def test_parse_complex_pipe(parser): @pytest.mark.parametrize( - 'line,output', [('help > out.txt', '>'), ('help>out.txt', '>'), ('help >> out.txt', '>>'), ('help>>out.txt', '>>'),] + 'line,output', + [ + ('help > out.txt', '>'), + ('help>out.txt', '>'), + ('help >> out.txt', '>>'), + ('help>>out.txt', '>>'), + ], ) def test_parse_redirect(parser, line, output): statement = parser.parse(line) @@ -277,7 +307,13 @@ def test_parse_redirect(parser, line, output): assert statement.expanded_command_line == statement.command + ' ' + statement.output + ' ' + statement.output_to -@pytest.mark.parametrize('dest', ['afile.txt', 'python-cmd2/afile.txt',]) # without dashes # with dashes in path +@pytest.mark.parametrize( + 'dest', + [ + 'afile.txt', + 'python-cmd2/afile.txt', + ], +) # without dashes # with dashes in path def test_parse_redirect_with_args(parser, dest): line = 'output into > {}'.format(dest) statement = parser.parse(line) @@ -668,7 +704,12 @@ def test_parse_alias_on_multiline_command(parser): @pytest.mark.parametrize( 'line,output', - [('helpalias > out.txt', '>'), ('helpalias>out.txt', '>'), ('helpalias >> out.txt', '>>'), ('helpalias>>out.txt', '>>'),], + [ + ('helpalias > out.txt', '>'), + ('helpalias>out.txt', '>'), + ('helpalias >> out.txt', '>>'), + ('helpalias>>out.txt', '>>'), + ], ) def test_parse_alias_redirection(parser, line, output): statement = parser.parse(line) @@ -679,7 +720,13 @@ def test_parse_alias_redirection(parser, line, output): assert statement.output_to == 'out.txt' -@pytest.mark.parametrize('line', ['helpalias | less', 'helpalias|less',]) +@pytest.mark.parametrize( + 'line', + [ + 'helpalias | less', + 'helpalias|less', + ], +) def test_parse_alias_pipe(parser, line): statement = parser.parse(line) assert statement.command == 'help' @@ -689,7 +736,15 @@ def test_parse_alias_pipe(parser, line): @pytest.mark.parametrize( - 'line', ['helpalias;', 'helpalias;;', 'helpalias;; ;', 'helpalias ;', 'helpalias ; ;', 'helpalias ;; ;',] + 'line', + [ + 'helpalias;', + 'helpalias;;', + 'helpalias;; ;', + 'helpalias ;', + 'helpalias ; ;', + 'helpalias ;; ;', + ], ) def test_parse_alias_terminator_no_whitespace(parser, line): statement = parser.parse(line) @@ -814,7 +869,22 @@ def test_parse_command_only_specialchars(parser, line, args): assert statement.output_to == '' -@pytest.mark.parametrize('line', ['', ';', ';;', ';; ;', '&', '& &', ' && &', '>', "'", '"', '|',]) +@pytest.mark.parametrize( + 'line', + [ + '', + ';', + ';;', + ';; ;', + '&', + '& &', + ' && &', + '>', + "'", + '"', + '|', + ], +) def test_parse_command_only_empty(parser, line): statement = parser.parse_command_only(line) assert statement == '' -- cgit v1.2.1