diff --git a/tests/composition/test_report.py b/tests/composition/test_report.py index 839aaaa3dbf..82e79dbf443 100644 --- a/tests/composition/test_report.py +++ b/tests/composition/test_report.py @@ -1,5 +1,3 @@ -import contextlib -import io import sys import numpy as np @@ -12,29 +10,25 @@ @pytest.mark.skipif(sys.platform == 'win32', reason="") class TestReport(): - def test_reportOutputPref_true(self): + def test_reportOutputPref_true(self, capsys): t = pnl.TransferMechanism() t.reportOutputPref = ReportOutput.FULL - f = io.StringIO() - with contextlib.redirect_stdout(f): - t.execute(1) - output = f.getvalue() + t.execute(1) + output = capsys.readouterr().out assert 'input: 1.0' in output assert 'output: 1.0' in output assert 'params' not in output - def test_reportOutputPref_params(self): + def test_reportOutputPref_params(self, capsys): t = pnl.TransferMechanism() t.reportOutputPref = 'params' - f = io.StringIO() - with contextlib.redirect_stdout(f): - t.execute(1, report_output=ReportOutput.FULL) - output = f.getvalue() + t.execute(1, report_output=ReportOutput.FULL) + output = capsys.readouterr().out assert 'input: 1.0' in output assert 'output: 1.0' in output