aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2018-12-29 21:02:53 +0100
committerGitHub <noreply@github.com>2018-12-29 21:02:53 +0100
commit7b6c498ac1faaec366690ed681fc12ad9de3d1f3 (patch)
tree889e42c9e37677cca6bf597b2972b5703b3c20b4 /tests
parent19f1cf536da6305c4dfab65a1b6ac269dab6c186 (diff)
downloadpyasn1-7b6c498ac1faaec366690ed681fc12ad9de3d1f3.tar.gz
Fix defaulted constructed SEQUENCE component initialization (#146)
When SEQUENCE has defaulted component of constructed type, recursively instantiate defaulted component and assign instantiated asn1 object to SEQUENCE field.
Diffstat (limited to 'tests')
-rw-r--r--tests/type/test_univ.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/type/test_univ.py b/tests/type/test_univ.py
index 44a3add..357c9e5 100644
--- a/tests/type/test_univ.py
+++ b/tests/type/test_univ.py
@@ -1407,6 +1407,22 @@ class Sequence(BaseTestCase):
s.clear()
assert s.getComponentByPosition(1, default=None) is None
+ def testGetComponentWithConstructedDefault(self):
+
+ class Sequence(univ.Sequence):
+ componentType = namedtype.NamedTypes(
+ namedtype.NamedType('name', univ.OctetString()),
+ namedtype.DefaultedNamedType('nick', univ.SequenceOf(
+ componentType=univ.Integer()
+ ).setComponentByPosition(0, 1)),
+ )
+
+ s = Sequence()
+
+ assert s.getComponentByPosition(1, default=None, instantiate=False) is None
+ assert s.getComponentByPosition(1, instantiate=False) is univ.noValue
+ assert s.getComponentByPosition(1) == [1]
+
def testGetComponentNoInstantiation(self):
class Sequence(univ.Sequence):