Skip to content

Commit

Permalink
Make use of capsys fixture in test
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb committed Jun 19, 2022
1 parent 0b89bc4 commit 6c6f615
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions tests/link/c/test_cmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import os
import sys
import tempfile
from contextlib import redirect_stderr, redirect_stdout
from io import StringIO
from unittest.mock import patch

import numpy as np
Expand Down Expand Up @@ -219,14 +217,11 @@ def mocked_blas_opt(*args, **kwargs):


@patch("numpy.distutils.system_info.get_info", new=mocked_blas_opt)
def test_blas_opt_warnings():
sio_out = StringIO()
sio_err = StringIO()
with redirect_stdout(sio_out):
with redirect_stderr(sio_err):
default_blas_ldflags()
stdout_lines = sio_out.getvalue().splitlines()
stderr_lines = sio_err.getvalue().splitlines()
def test_blas_opt_warnings(capsys):
default_blas_ldflags()
captured_messages = capsys.readouterr()
stdout_lines = captured_messages.out.splitlines()
stderr_lines = captured_messages.err.splitlines()
assert stdout_lines == [
"This line will be re-printed to stdout",
"Could not locate executable foo: this line will be re-printed to stdout",
Expand Down

0 comments on commit 6c6f615

Please sign in to comment.