summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/test/cmd/info.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/lib/spack/spack/test/cmd/info.py b/lib/spack/spack/test/cmd/info.py
index a5e8ae0bd8..57176a4784 100644
--- a/lib/spack/spack/test/cmd/info.py
+++ b/lib/spack/spack/test/cmd/info.py
@@ -26,18 +26,14 @@ def parser():
@pytest.fixture()
-def info_lines():
- lines = []
- return lines
-
-
-@pytest.fixture()
-def mock_print(monkeypatch, info_lines):
+def print_buffer(monkeypatch):
+ buffer = []
def _print(*args):
- info_lines.extend(args)
+ buffer.extend(args)
monkeypatch.setattr(spack.cmd.info.color, 'cprint', _print, raising=False)
+ return buffer
@pytest.mark.parametrize('pkg', [
@@ -52,11 +48,11 @@ def test_it_just_runs(pkg):
info(pkg)
-def test_info_noversion(mock_packages, info_lines, mock_print):
+def test_info_noversion(mock_packages, print_buffer):
"""Check that a mock package with no versions or variants outputs None."""
info('noversion')
- line_iter = info_lines.__iter__()
+ line_iter = iter(print_buffer)
for line in line_iter:
if 'version' in line:
has = [desc in line for desc in ['Preferred', 'Safe', 'Deprecated']]
@@ -72,12 +68,11 @@ def test_info_noversion(mock_packages, info_lines, mock_print):
('zlib', 'False'),
('gcc', 'True (version, variants)'),
])
-@pytest.mark.usefixtures('mock_print')
-def test_is_externally_detectable(pkg_query, expected, parser, info_lines):
+def test_is_externally_detectable(pkg_query, expected, parser, print_buffer):
args = parser.parse_args(['--detectable', pkg_query])
spack.cmd.info.info(parser, args)
- line_iter = info_lines.__iter__()
+ line_iter = iter(print_buffer)
for line in line_iter:
if 'Externally Detectable' in line:
is_externally_detectable = next(line_iter).strip()
@@ -90,9 +85,7 @@ def test_is_externally_detectable(pkg_query, expected, parser, info_lines):
'trilinos',
'gcc' # This should ensure --test's c_names processing loop covered
])
-@pytest.mark.usefixtures('mock_print')
-def test_info_fields(pkg_query, parser, info_lines):
-
+def test_info_fields(pkg_query, parser, print_buffer):
expected_fields = (
'Description:',
'Homepage:',
@@ -108,5 +101,4 @@ def test_info_fields(pkg_query, parser, info_lines):
spack.cmd.info.info(parser, args)
for text in expected_fields:
- match = [x for x in info_lines if text in x]
- assert match
+ assert any(x for x in print_buffer if text in x)