blob: 2aaded2c65e1f7565d78ea3d629308727f359825 [file] [log] [blame]
Alex Gaynorde1906a2014-08-12 16:12:54 -07001from OpenSSL._util import exception_from_error_queue, lib
Hynek Schlawackf0e66852015-10-16 20:18:38 +02002
3from .util import TestCase
Alex Gaynorde1906a2014-08-12 16:12:54 -07004
5
Jean-Paul Calderone174c6922015-04-11 07:26:15 -04006class ErrorTests(TestCase):
7 """
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 """
Jean-Paul Calderone174c6922015-04-11 07:26:15 -040012 :py:func:`exception_from_error_queue` raises ``ValueError`` when it
13 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)
Hynek Schlawacke69d8452015-09-05 09:51:09 +020016 exc = self.assertRaises(
17 ValueError, exception_from_error_queue, ValueError
18 )
Alex Gaynorde1906a2014-08-12 16:12:54 -070019 self.assertEqual(exc.args[0][0][2], "")