Use pytest's capsys to test for stdout values

Works better with pytest's output capturing system
pull/496/head
yuvipanda 2018-12-14 13:29:14 -08:00
rodzic a9f45e6fae
commit 3a85fb814b
1 zmienionych plików z 5 dodań i 8 usunięć

Wyświetl plik

@ -6,18 +6,15 @@ import pytest
import logging
from repo2docker.__main__ import make_r2d
from repo2docker import __version__
from contextlib import redirect_stdout
import io
def test_version():
def test_version(capsys):
"""
Test passing '--version' to repo2docker
"""
stdout = io.StringIO()
with redirect_stdout(stdout):
with pytest.raises(SystemExit):
make_r2d(['--version'])
assert stdout.getvalue().strip() == __version__
with pytest.raises(SystemExit):
make_r2d(['--version'])
assert capsys.readouterr().out == f"{__version__}\n"
def test_simple():
"""