diff options
author | José Padilla <jpadilla@webapplicate.com> | 2017-11-05 09:27:08 -0500 |
---|---|---|
committer | José Padilla <jpadilla@webapplicate.com> | 2017-11-05 09:27:08 -0500 |
commit | 99c1ee928af045c9b15fdce9c60cb4fbf6157ed1 (patch) | |
tree | 565947731c18db7b64d5ab8291cad250f8cd0d57 | |
parent | 6031675263721d540f2a2e22a3ed6685eb3aec5f (diff) | |
download | pyjwt-fix-298.tar.gz |
Add test to cover when terminal is not a TTYfix-298
-rw-r--r-- | tests/test_cli.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py index f08cf6b..422dc9d 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -57,6 +57,19 @@ class TestCli: assert 'There was an error decoding the token' in str(excinfo.value) + def test_decode_payload_raises_terminal_not_a_tty(self, monkeypatch): + decode_args = ['--key', '1234', 'decode'] + parser = build_argparser() + args = parser.parse_args(decode_args) + + monkeypatch.setattr(sys.stdin, 'isatty', lambda: False) + monkeypatch.setattr(sys.stdin, 'read', lambda: 'token') + + with pytest.raises(IOError) as excinfo: + decode_payload(args) + assert 'Cannot read from stdin: terminal not a TTY' \ + in str(excinfo.value) + @pytest.mark.parametrize('key,name,job,exp,verify', [ ('1234', 'Vader', 'Sith', None, None), ('4567', 'Anakin', 'Jedi', '+1', None), |