Skip to content

Commit 9798d6d

Browse files
ch3pjwhoefling
authored andcommitted
Test TypeError when setting non-callable callbacks
1 parent 7b41f27 commit 9798d6d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/test_main.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,16 @@ def _expect_sign_failure(self):
6262
with self.assertRaisesRegex(xmlsec.Error, 'failed to sign'):
6363
self._sign_doc()
6464

65-
def _register_mismatch_callbacks(self, match_cb=lambda filename: False):
66-
xmlsec.register_callbacks(
65+
def _mismatch_callbacks(self, match_cb=lambda filename: False):
66+
return [
6767
match_cb,
6868
lambda filename: None,
6969
lambda none, buf: 0,
7070
lambda none: None,
71-
)
71+
]
72+
73+
def _register_mismatch_callbacks(self, match_cb=lambda filename: False):
74+
xmlsec.register_callbacks(*self._mismatch_callbacks(match_cb))
7275

7376
def _register_match_callbacks(self):
7477
xmlsec.register_callbacks(
@@ -147,3 +150,9 @@ def mismatch_cb(filename):
147150
self._register_mismatch_callbacks(mismatch_cb)
148151
self._expect_sign_failure()
149152
self.assertEqual(mismatch_calls, 2)
153+
154+
def test_register_non_callables(self):
155+
for idx in range(4):
156+
cbs = self._mismatch_callbacks()
157+
cbs[idx] = None
158+
self.assertRaises(TypeError, xmlsec.register_callbacks, *cbs)

0 commit comments

Comments
 (0)