Skip to content

Commit

Permalink
Add isatty fixture and use monkeypatch
Browse files Browse the repository at this point in the history
  • Loading branch information
tomschr committed Sep 29, 2016
1 parent 0fa65e2 commit 68d8317
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/test_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
from sdsc import printcolor


@pytest.mark.parametrize("msg",
("a", "b\nc")
@pytest.mark.parametrize("msg", ("hello",)
)
@pytest.mark.parametrize("msgtype",
("error", "debug", None)
)
# @pytest.mark.parametrize('isatty', (True, False))
def test_printcolor(capsys, msg, msgtype):
@pytest.mark.parametrize('isatty', (True, False))
def test_printcolor(capsys, monkeypatch, msg, msgtype, isatty):
"""Checks printcolor() function
:param capsys:
:param str msg:
:param str msgtype:
:param capsys:
:param bool isatty:
"""
monkeypatch.setattr('sys.stdout.isatty', lambda: isatty)

printcolor(msg, msgtype)
if msgtype in ('debug', 'error'):
assert capsys.readouterr()[0].count(msg) == 0
Expand Down

0 comments on commit 68d8317

Please sign in to comment.