test_util.py 618 B

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