From 6642e42c56bf936408a9c889bb1483516ef02e23 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 15:54:20 -0400 Subject: Experimenting with enabling a simple CompletionFinder unit test on TravisCI --- tests/test_bashcompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index e2c28fce..a29d39df 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -103,7 +103,7 @@ def parser1(): # noinspection PyShadowingNames -@pytest.mark.skipif(skip, reason=skip_reason) +@pytest.mark.skipif(skip, reason=(skip_reason1 or skip_reason3)) def test_bash_nocomplete(parser1): completer = CompletionFinder() result = completer(parser1, AutoCompleter(parser1)) -- cgit v1.2.1 From 231a8e97641ab4576403fc3ba3432814f28a37ae Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 15:56:56 -0400 Subject: Fixed logic of test --- tests/test_bashcompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index a29d39df..04a564f4 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -103,7 +103,7 @@ def parser1(): # noinspection PyShadowingNames -@pytest.mark.skipif(skip, reason=(skip_reason1 or skip_reason3)) +@pytest.mark.skipif(skip_reason1 or skip_reason3, reason=skip_reason) def test_bash_nocomplete(parser1): completer = CompletionFinder() result = completer(parser1, AutoCompleter(parser1)) -- cgit v1.2.1 From b37b938bc4b7add3f3ef7ff86147b1d224592b86 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 15:59:51 -0400 Subject: Enable another test --- tests/test_bashcompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index 04a564f4..373f3fe7 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -122,7 +122,7 @@ def my_fdopen(fd, mode, *args): # noinspection PyShadowingNames -@pytest.mark.skipif(skip, reason=skip_reason) +@pytest.mark.skipif(skip_reason1 or skip_reason3, reason=skip_reason) def test_invalid_ifs(parser1, mock): completer = CompletionFinder() -- cgit v1.2.1 From befd01b282ed625dbcff7623b5d39427f76f6ecf Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 16:03:35 -0400 Subject: Renamed some variables - Also enabled another test --- tests/test_bashcompletion.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index 373f3fe7..2e7ac398 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -16,22 +16,22 @@ from cmd2.argparse_completer import ACArgumentParser, AutoCompleter try: from cmd2.argcomplete_bridge import CompletionFinder, tokens_for_completion - skip_reason1 = False + skip_no_argcomplete = False skip_reason = '' except ImportError: # Don't test if argcomplete isn't present (likely on Windows) - skip_reason1 = True + skip_no_argcomplete = True skip_reason = "argcomplete isn't installed\n" -skip_reason2 = "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true" -if skip_reason2: +skip_travis = "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true" +if skip_travis: skip_reason += 'These tests cannot run on TRAVIS\n' -skip_reason3 = sys.platform.startswith('win') -if skip_reason3: +skip_windows = sys.platform.startswith('win') +if skip_windows: skip_reason = 'argcomplete doesn\'t support Windows' -skip = skip_reason1 or skip_reason2 or skip_reason3 +skip = skip_no_argcomplete or skip_travis or skip_windows skip_mac = sys.platform.startswith('dar') @@ -103,7 +103,7 @@ def parser1(): # noinspection PyShadowingNames -@pytest.mark.skipif(skip_reason1 or skip_reason3, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete or skip_windows, reason=skip_reason) def test_bash_nocomplete(parser1): completer = CompletionFinder() result = completer(parser1, AutoCompleter(parser1)) @@ -122,7 +122,7 @@ def my_fdopen(fd, mode, *args): # noinspection PyShadowingNames -@pytest.mark.skipif(skip_reason1 or skip_reason3, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete or skip_windows, reason=skip_reason) def test_invalid_ifs(parser1, mock): completer = CompletionFinder() @@ -136,7 +136,7 @@ def test_invalid_ifs(parser1, mock): # noinspection PyShadowingNames -@pytest.mark.skipif(skip or skip_mac, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete or skip_windows or skip_mac, reason=skip_reason) @pytest.mark.parametrize('comp_line, exp_out, exp_err', [ ('media ', 'movies\013shows', ''), ('media mo', 'movies', ''), @@ -232,7 +232,7 @@ Hint: assert out == exp_out assert err == exp_err -@pytest.mark.skipif(skip_reason1, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete, reason=skip_reason) def test_argcomplete_tokens_for_completion_simple(): line = 'this is "a test"' endidx = len(line) @@ -243,7 +243,7 @@ def test_argcomplete_tokens_for_completion_simple(): assert begin_idx == line.rfind("is ") + len("is ") assert end_idx == end_idx -@pytest.mark.skipif(skip_reason1, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete, reason=skip_reason) def test_argcomplete_tokens_for_completion_unclosed_quotee_exception(): line = 'this is "a test' endidx = len(line) -- cgit v1.2.1 From e570d5cad9e4a08588657673d60139375051377d Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 16:08:26 -0400 Subject: Get back to passing state with renamed variables --- tests/test_bashcompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index 2e7ac398..251732c9 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -136,7 +136,7 @@ def test_invalid_ifs(parser1, mock): # noinspection PyShadowingNames -@pytest.mark.skipif(skip_no_argcomplete or skip_windows or skip_mac, reason=skip_reason) +@pytest.mark.skipif(skip or skip_mac, reason=skip_reason) @pytest.mark.parametrize('comp_line, exp_out, exp_err', [ ('media ', 'movies\013shows', ''), ('media mo', 'movies', ''), -- cgit v1.2.1 From 34b487cf3596fdec414bd151277717ab8586adde Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 16:11:06 -0400 Subject: Try adding another test --- tests/test_bashcompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index 251732c9..47fcdb34 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -176,7 +176,7 @@ def fdopen_fail_8(fd, mode, *args): # noinspection PyShadowingNames -@pytest.mark.skipif(skip, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete or skip_windows, reason=skip_reason) def test_fail_alt_stdout(parser1, mock): completer = CompletionFinder() -- cgit v1.2.1 From c0035fe571d734f8bb234dee577df0e2005cc3e4 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 16:12:54 -0400 Subject: Try adding one more --- tests/test_bashcompletion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index 47fcdb34..2060ec5d 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -205,7 +205,7 @@ def fdopen_fail_9(fd, mode, *args): # noinspection PyShadowingNames -@pytest.mark.skipif(skip or skip_mac, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete or skip_windows or skip_mac, reason=skip_reason) def test_fail_alt_stderr(parser1, capfd, mock): completer = CompletionFinder() -- cgit v1.2.1 From 0e0e22d3a53ea3ea3f6b34933df73f6b0e1dc071 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 16:22:29 -0400 Subject: Trying to start including some but not all of the parameterized bash completion tests --- tests/test_bashcompletion.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index 2060ec5d..b0607ec8 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -136,9 +136,34 @@ def test_invalid_ifs(parser1, mock): # noinspection PyShadowingNames -@pytest.mark.skipif(skip or skip_mac, reason=skip_reason) +@pytest.mark.skipif(skip_no_argcomplete or skip_windows or skip_mac, reason=skip_reason) @pytest.mark.parametrize('comp_line, exp_out, exp_err', [ ('media ', 'movies\013shows', ''), +]) +def test_commands_travis(parser1, capfd, mock, comp_line, exp_out, exp_err): + mock.patch.dict(os.environ, {'_ARGCOMPLETE': '1', + '_ARGCOMPLETE_IFS': '\013', + 'COMP_TYPE': '63', + 'COMP_LINE': comp_line, + 'COMP_POINT': str(len(comp_line))}) + + mock.patch.object(os, 'fdopen', my_fdopen) + + with pytest.raises(SystemExit): + completer = CompletionFinder() + + choices = {'actor': query_actors, # function + } + autocompleter = AutoCompleter(parser1, arg_choices=choices) + completer(parser1, autocompleter, exit_method=sys.exit) + + out, err = capfd.readouterr() + assert out == exp_out + assert err == exp_err + +# noinspection PyShadowingNames +@pytest.mark.skipif(skip or skip_mac, reason=skip_reason) +@pytest.mark.parametrize('comp_line, exp_out, exp_err', [ ('media mo', 'movies', ''), ('media movies list -a "J', '"John Boyega"\013"Jake Lloyd"', ''), ('media movies list ', '', ''), @@ -146,7 +171,7 @@ def test_invalid_ifs(parser1, mock): Hint: TITLE Movie Title'''), ]) -def test_commands(parser1, capfd, mock, comp_line, exp_out, exp_err): +def test_commands_local(parser1, capfd, mock, comp_line, exp_out, exp_err): mock.patch.dict(os.environ, {'_ARGCOMPLETE': '1', '_ARGCOMPLETE_IFS': '\013', 'COMP_TYPE': '63', @@ -205,7 +230,7 @@ def fdopen_fail_9(fd, mode, *args): # noinspection PyShadowingNames -@pytest.mark.skipif(skip_no_argcomplete or skip_windows or skip_mac, reason=skip_reason) +@pytest.mark.skipif(skip or skip_mac, reason=skip_reason) def test_fail_alt_stderr(parser1, capfd, mock): completer = CompletionFinder() -- cgit v1.2.1 From 10e703682a194ad692616d0c240def4c90fbd748 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 16:29:36 -0400 Subject: 2nd try at selectively enabling parameterized --- tests/test_bashcompletion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index b0607ec8..a630fd3c 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -138,7 +138,7 @@ def test_invalid_ifs(parser1, mock): # noinspection PyShadowingNames @pytest.mark.skipif(skip_no_argcomplete or skip_windows or skip_mac, reason=skip_reason) @pytest.mark.parametrize('comp_line, exp_out, exp_err', [ - ('media ', 'movies\013shows', ''), + ('media mo', 'movies', ''), ]) def test_commands_travis(parser1, capfd, mock, comp_line, exp_out, exp_err): mock.patch.dict(os.environ, {'_ARGCOMPLETE': '1', @@ -164,7 +164,7 @@ def test_commands_travis(parser1, capfd, mock, comp_line, exp_out, exp_err): # noinspection PyShadowingNames @pytest.mark.skipif(skip or skip_mac, reason=skip_reason) @pytest.mark.parametrize('comp_line, exp_out, exp_err', [ - ('media mo', 'movies', ''), + ('media ', 'movies\013shows', ''), ('media movies list -a "J', '"John Boyega"\013"Jake Lloyd"', ''), ('media movies list ', '', ''), ('media movies add ', '\013\013 ', ''' -- cgit v1.2.1 From bcf4091723d5f1d5ac14ce8df98236d65f522da8 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Sat, 9 Jun 2018 16:32:45 -0400 Subject: Going back to all parameterized bash completion tests disabled on TravisCI --- tests/test_bashcompletion.py | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'tests/test_bashcompletion.py') diff --git a/tests/test_bashcompletion.py b/tests/test_bashcompletion.py index a630fd3c..47fcdb34 100644 --- a/tests/test_bashcompletion.py +++ b/tests/test_bashcompletion.py @@ -135,43 +135,18 @@ def test_invalid_ifs(parser1, mock): completer(parser1, AutoCompleter(parser1), exit_method=sys.exit) -# noinspection PyShadowingNames -@pytest.mark.skipif(skip_no_argcomplete or skip_windows or skip_mac, reason=skip_reason) -@pytest.mark.parametrize('comp_line, exp_out, exp_err', [ - ('media mo', 'movies', ''), -]) -def test_commands_travis(parser1, capfd, mock, comp_line, exp_out, exp_err): - mock.patch.dict(os.environ, {'_ARGCOMPLETE': '1', - '_ARGCOMPLETE_IFS': '\013', - 'COMP_TYPE': '63', - 'COMP_LINE': comp_line, - 'COMP_POINT': str(len(comp_line))}) - - mock.patch.object(os, 'fdopen', my_fdopen) - - with pytest.raises(SystemExit): - completer = CompletionFinder() - - choices = {'actor': query_actors, # function - } - autocompleter = AutoCompleter(parser1, arg_choices=choices) - completer(parser1, autocompleter, exit_method=sys.exit) - - out, err = capfd.readouterr() - assert out == exp_out - assert err == exp_err - # noinspection PyShadowingNames @pytest.mark.skipif(skip or skip_mac, reason=skip_reason) @pytest.mark.parametrize('comp_line, exp_out, exp_err', [ ('media ', 'movies\013shows', ''), + ('media mo', 'movies', ''), ('media movies list -a "J', '"John Boyega"\013"Jake Lloyd"', ''), ('media movies list ', '', ''), ('media movies add ', '\013\013 ', ''' Hint: TITLE Movie Title'''), ]) -def test_commands_local(parser1, capfd, mock, comp_line, exp_out, exp_err): +def test_commands(parser1, capfd, mock, comp_line, exp_out, exp_err): mock.patch.dict(os.environ, {'_ARGCOMPLETE': '1', '_ARGCOMPLETE_IFS': '\013', 'COMP_TYPE': '63', -- cgit v1.2.1