Skip to content

Commit 7d07826

Browse files
committed
Maybe this will do the trick.
1 parent efc6ab8 commit 7d07826

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

tests/test_bashcompletion.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,27 @@
1111
from typing import List
1212

1313
from cmd2.argparse_completer import ACArgumentParser, AutoCompleter
14+
15+
1416
try:
1517
from cmd2.argcomplete_bridge import CompletionFinder
16-
except:
18+
skip_reason1 = False
19+
skip_reason = ''
20+
except ImportError:
1721
# Don't test if argcomplete isn't present (likely on Windows)
18-
pytest.skip()
22+
skip_reason1 = True
23+
skip_reason = "argcomplete isn't installed\n"
24+
25+
26+
skip_reason2 = "TRAVIS" in os.environ and os.environ["TRAVIS"] == "true"
27+
if skip_reason2:
28+
skip_reason += 'These tests cannot run on TRAVIS\n'
29+
skip_reason3 = sys.platform.startswith('win')
30+
if skip_reason3:
31+
skip_reason = 'argcomplete doesn\'t support Windows'
32+
33+
skip = skip_reason1 or skip_reason2 or skip_reason3
34+
1935

2036
actors = ['Mark Hamill', 'Harrison Ford', 'Carrie Fisher', 'Alec Guinness', 'Peter Mayhew',
2137
'Anthony Daniels', 'Adam Driver', 'Daisy Ridley', 'John Boyega', 'Oscar Isaac',
@@ -84,6 +100,7 @@ def _do_media_shows(self, args) -> None:
84100

85101

86102
# noinspection PyShadowingNames
103+
@pytest.mark.skipif(skip, reason=skip_reason)
87104
def test_bash_nocomplete(parser1):
88105
completer = CompletionFinder()
89106
result = completer(parser1, AutoCompleter(parser1))
@@ -102,6 +119,7 @@ def my_fdopen(fd, mode):
102119

103120

104121
# noinspection PyShadowingNames
122+
@pytest.mark.skipif(skip, reason=skip_reason)
105123
def test_invalid_ifs(parser1, mock):
106124
completer = CompletionFinder()
107125

@@ -115,6 +133,7 @@ def test_invalid_ifs(parser1, mock):
115133

116134

117135
# noinspection PyShadowingNames
136+
@pytest.mark.skipif(skip, reason=skip_reason)
118137
@pytest.mark.parametrize('comp_line, exp_out, exp_err', [
119138
('media ', 'movies\013shows', ''),
120139
('media mo', 'movies', ''),
@@ -154,6 +173,7 @@ def fdopen_fail_8(fd, mode):
154173

155174

156175
# noinspection PyShadowingNames
176+
@pytest.mark.skipif(skip, reason=skip_reason)
157177
def test_fail_alt_stdout(parser1, mock):
158178
completer = CompletionFinder()
159179

@@ -182,6 +202,7 @@ def fdopen_fail_9(fd, mode):
182202

183203

184204
# noinspection PyShadowingNames
205+
@pytest.mark.skipif(skip, reason=skip_reason)
185206
def test_fail_alt_stderr(parser1, capfd, mock):
186207
completer = CompletionFinder()
187208

0 commit comments

Comments
 (0)