blob: 91847e037aa8b971fc9a2e49dfe84bd157fac8fc [file] [log] [blame]
Alex Chan67666e22016-10-24 16:47:39 +01001import pytest
Alex Gaynorde1906a2014-08-12 16:12:54 -07002
Hynek Schlawackd52975c2017-05-13 17:44:27 +02003from OpenSSL._util import exception_from_error_queue, lib
4
Alex Gaynorde1906a2014-08-12 16:12:54 -07005
Alex Chan67666e22016-10-24 16:47:39 +01006class TestErrors(object):
Jean-Paul Calderone174c6922015-04-11 07:26:15 -04007 """
8 Tests for handling of certain OpenSSL error cases.
9 """
Alex Gaynor27f55ed2014-08-15 11:24:26 -070010 def test_exception_from_error_queue_nonexistent_reason(self):
Alex Gaynor98232392014-08-15 11:23:00 -070011 """
Hynek Schlawackd52975c2017-05-13 17:44:27 +020012 :func:`exception_from_error_queue` raises ``ValueError`` when it
Jean-Paul Calderone174c6922015-04-11 07:26:15 -040013 encounters an OpenSSL error code which does not have a reason string.
Alex Gaynor98232392014-08-15 11:23:00 -070014 """
Alex Gaynorbae2dc32014-08-14 13:44:54 -070015 lib.ERR_put_error(lib.ERR_LIB_EVP, 0, 1112, b"", 10)
Alex Chan67666e22016-10-24 16:47:39 +010016 with pytest.raises(ValueError) as exc:
17 exception_from_error_queue(ValueError)
18 assert exc.value.args[0][0][2] == ""