X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=tests%2Ftest_pyderasn.py;h=dfea4300e78a6e4ccc8c17cd05457e6a3bc07fb6;hb=8604ed7e5f423239c839e4bfacd3a585daf0b320;hp=f8377e8881e6e4454758372c28196edac0f57c80;hpb=3533e4b3ccb7c353bc13f924b82aae0398968d43;p=pyderasn.git diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py index f8377e8..dfea430 100644 --- a/tests/test_pyderasn.py +++ b/tests/test_pyderasn.py @@ -108,11 +108,11 @@ from pyderasn import VideotexString from pyderasn import VisibleString -settings.register_profile('local', settings( +settings.register_profile("local", settings( deadline=5000, perform_health_check=False, )) -settings.load_profile('local') +settings.load_profile("local") LONG_TEST_MAX_EXAMPLES = settings().max_examples * 4 tag_classes = sampled_from(( @@ -2806,7 +2806,7 @@ class TestUTF8String(StringMixin, CommonMixin, TestCase): class UnicodeDecodeErrorMixin(object): @given(text( - alphabet=''.join(six_unichr(i) for i in list(range(0x0410, 0x044f + 1))), + alphabet="".join(six_unichr(i) for i in list(range(0x0410, 0x044f + 1))), min_size=1, max_size=5, )) @@ -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): @@ -3947,7 +3967,7 @@ def sequences_strategy(draw, seq_klass): class SeqMixing(object): def test_invalid_value_type(self): with self.assertRaises(InvalidValueType) as err: - self.base_klass((1, 2, 3)) + self.base_klass(123) repr(err.exception) def test_invalid_value_type_set(self):