Alex Gaynor | de1906a | 2014-08-12 16:12:54 -0700 | [diff] [blame] | 1 | from OpenSSL._util import exception_from_error_queue, lib |
Hynek Schlawack | f0e6685 | 2015-10-16 20:18:38 +0200 | [diff] [blame] | 2 | |
Alex Chan | 67666e2 | 2016-10-24 16:47:39 +0100 | [diff] [blame^] | 3 | import pytest |
Alex Gaynor | de1906a | 2014-08-12 16:12:54 -0700 | [diff] [blame] | 4 | |
| 5 | |
Alex Chan | 67666e2 | 2016-10-24 16:47:39 +0100 | [diff] [blame^] | 6 | class TestErrors(object): |
Jean-Paul Calderone | 174c692 | 2015-04-11 07:26:15 -0400 | [diff] [blame] | 7 | """ |
| 8 | Tests for handling of certain OpenSSL error cases. |
| 9 | """ |
Alex Gaynor | 27f55ed | 2014-08-15 11:24:26 -0700 | [diff] [blame] | 10 | def test_exception_from_error_queue_nonexistent_reason(self): |
Alex Gaynor | 9823239 | 2014-08-15 11:23:00 -0700 | [diff] [blame] | 11 | """ |
Jean-Paul Calderone | 174c692 | 2015-04-11 07:26:15 -0400 | [diff] [blame] | 12 | :py:func:`exception_from_error_queue` raises ``ValueError`` when it |
| 13 | encounters an OpenSSL error code which does not have a reason string. |
Alex Gaynor | 9823239 | 2014-08-15 11:23:00 -0700 | [diff] [blame] | 14 | """ |
Alex Gaynor | bae2dc3 | 2014-08-14 13:44:54 -0700 | [diff] [blame] | 15 | lib.ERR_put_error(lib.ERR_LIB_EVP, 0, 1112, b"", 10) |
Alex Chan | 67666e2 | 2016-10-24 16:47:39 +0100 | [diff] [blame^] | 16 | with pytest.raises(ValueError) as exc: |
| 17 | exception_from_error_queue(ValueError) |
| 18 | assert exc.value.args[0][0][2] == "" |