1import pytest
2
3from OpenSSL._util import exception_from_error_queue, lib
4
5
6class TestErrors(object):
7    """
8    Tests for handling of certain OpenSSL error cases.
9    """
10
11    def test_exception_from_error_queue_nonexistent_reason(self):
12        """
13        :func:`exception_from_error_queue` raises ``ValueError`` when it
14        encounters an OpenSSL error code which does not have a reason string.
15        """
16        lib.ERR_put_error(lib.ERR_LIB_EVP, 0, 1112, b"", 10)
17        with pytest.raises(ValueError) as exc:
18            exception_from_error_queue(ValueError)
19        assert exc.value.args[0][0][2] == ""
20