]> Cypherpunks.ru repositories - pyderasn.git/blobdiff - tests/test_pyderasn.py
Do not shadow TagMismatch error during Choice/Set decoding
[pyderasn.git] / tests / test_pyderasn.py
index 401d6237222ead8c0308e9f2fe05292bedfcd3c3..723020c4820802e2970d87712bbb879a36146ece 100644 (file)
@@ -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):