X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=blobdiff_plain;f=tests%2Ftest_pyderasn.py;h=723020c4820802e2970d87712bbb879a36146ece;hp=401d6237222ead8c0308e9f2fe05292bedfcd3c3;hb=277095bb49de4020e8fa47c216dcf1abe7a910d7;hpb=a58ad9185841958da6b539def1458450a2b68d31 diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py index 401d623..723020c 100644 --- a/tests/test_pyderasn.py +++ b/tests/test_pyderasn.py @@ -3772,6 +3772,26 @@ class TestChoice(CommonMixin, TestCase): with self.assertRaises(TagMismatch): obj.decode(int_encoded) + def test_tag_mismatch_underlying(self): + class SeqOfBoolean(SequenceOf): + schema = Boolean() + + class SeqOfInteger(SequenceOf): + schema = Integer() + + class Wahl(Choice): + schema = ( + ("erste", SeqOfBoolean()), + ) + + int_encoded = SeqOfInteger((Integer(123),)).encode() + bool_encoded = SeqOfBoolean((Boolean(False),)).encode() + obj = Wahl() + obj.decode(bool_encoded) + with self.assertRaises(TagMismatch) as err: + obj.decode(int_encoded) + self.assertEqual(err.exception.decode_path, ("erste", "0")) + @composite def seq_values_strategy(draw, seq_klass, do_expl=False):