Skip to content

Commit

Permalink
Use patch as contextmanager in test_help
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jan 10, 2020
1 parent c3336c9 commit 1a9318e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/commands/test_echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from tests import assert_streaming, assert_streaming_error, read, run_streaming


def test_help(monkeypatch, caplog):
@patch('sys.stdout', new_callable=StringIO)
def test_help(stdout, monkeypatch, caplog):
stdin = read('release-package_minimal.json', 'rb')

with pytest.raises(SystemExit) as excinfo:
with patch('sys.stdin', TextIOWrapper(BytesIO(stdin))), patch('sys.stdout', new_callable=StringIO) as stdout:
with patch('sys.stdin', TextIOWrapper(BytesIO(stdin))):
monkeypatch.setattr(sys, 'argv', ['ocdskit', '--help'])
main()

Expand Down

0 comments on commit 1a9318e

Please sign in to comment.