From aa3b6e598f8a504ee00c86cc3035482e642d2874 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 10 Dec 2022 11:59:59 -0800 Subject: `pkg grep`: use `capfd` instead of executable for tests --- lib/spack/spack/test/cmd/pkg.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/test/cmd/pkg.py b/lib/spack/spack/test/cmd/pkg.py index 2f1a1a6f3a..3f0b89309b 100644 --- a/lib/spack/spack/test/cmd/pkg.py +++ b/lib/spack/spack/test/cmd/pkg.py @@ -297,19 +297,19 @@ def test_pkg_hash(mock_packages): @pytest.mark.skipif(not spack.cmd.pkg.get_grep(), reason="grep is not installed") -def test_pkg_grep(mock_packages, capsys): +def test_pkg_grep(mock_packages, capfd): # only splice-* mock packages have the string "splice" in them - with capsys.disabled(): - output = pkg("grep", "-l", "splice", output=str) - + pkg("grep", "-l", "splice", output=str) + output, _ = capfd.readouterr() assert output.strip() == "\n".join( spack.repo.path.get_pkg_class(name).module.__file__ for name in ["splice-a", "splice-h", "splice-t", "splice-vh", "splice-z"] ) # ensure that this string isn't fouhnd - output = pkg("grep", "abcdefghijklmnopqrstuvwxyz", output=str, fail_on_error=False) + pkg("grep", "abcdefghijklmnopqrstuvwxyz", output=str, fail_on_error=False) assert pkg.returncode == 1 + output, _ = capfd.readouterr() assert output.strip() == "" # ensure that we return > 1 for an error -- cgit v1.2.3-70-g09d2