aboutsummaryrefslogtreecommitdiff
path: root/tests/codec
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-06-23 19:48:31 +0200
committerGitHub <noreply@github.com>2019-06-23 19:48:31 +0200
commit66d329acaaf204eff63ae595fd7d6f56cd530c72 (patch)
tree46187ae1df17aa9eb728abc2c55ef5ce612c6764 /tests/codec
parentb028644dea4244f1cd2513ab0241c8cb9be43324 (diff)
downloadpyasn1-66d329acaaf204eff63ae595fd7d6f56cd530c72.tar.gz
SequenceOf/SetOf to remain a schema objects (#162)
* Add `omitEmptyOptionals` encoder option Added `omitEmptyOptionals` option which is respected by `Sequence` and `Set` encoders. When `omitEmptyOptionals` is set to `True`, empty initialized optional components are not encoded. Default is `False`. * Change `SequenceOf`/`SetOf` behaviour - New elements to `SequenceOf`/`SetOf` objects can now be added at any position - the requirement for the new elements to reside at the end of the existing ones (i.e. s[len(s)] = 123) is removed. - Removed default initializer from `SequenceOf`/`SetOf` types to ensure consistent behaviour with the rest of ASN.1 types. Before this change, `SequenceOf`/`SetOf` instances immediately become value objects behaving like an empty list. With this change, `SequenceOf`/`SetOf` objects remain schema objects unless a component is added or `.clear()` is called. - Added `.reset()` method to all constructed types to turn value object into a schema object.
Diffstat (limited to 'tests/codec')
-rw-r--r--tests/codec/ber/test_encoder.py2
-rw-r--r--tests/codec/cer/test_encoder.py2
2 files changed, 4 insertions, 0 deletions
diff --git a/tests/codec/ber/test_encoder.py b/tests/codec/ber/test_encoder.py
index 26819bd..da14830 100644
--- a/tests/codec/ber/test_encoder.py
+++ b/tests/codec/ber/test_encoder.py
@@ -476,6 +476,7 @@ class UTF8StringEncoderWithSchemaTestCase(BaseTestCase):
class SequenceOfEncoderTestCase(BaseTestCase):
def testEmpty(self):
s = univ.SequenceOf()
+ s.clear()
assert encoder.encode(s) == ints2octs((48, 0))
def testDefMode(self):
@@ -570,6 +571,7 @@ class SequenceOfEncoderWithComponentsSchemaTestCase(BaseTestCase):
class SetOfEncoderTestCase(BaseTestCase):
def testEmpty(self):
s = univ.SetOf()
+ s.clear()
assert encoder.encode(s) == ints2octs((49, 0))
def testDefMode(self):
diff --git a/tests/codec/cer/test_encoder.py b/tests/codec/cer/test_encoder.py
index d9d9212..ea8f813 100644
--- a/tests/codec/cer/test_encoder.py
+++ b/tests/codec/cer/test_encoder.py
@@ -155,6 +155,7 @@ class UTCTimeEncoderTestCase(BaseTestCase):
class SequenceOfEncoderTestCase(BaseTestCase):
def testEmpty(self):
s = univ.SequenceOf()
+ s.clear()
assert encoder.encode(s) == ints2octs((48, 128, 0, 0))
def testDefMode1(self):
@@ -219,6 +220,7 @@ class SequenceOfEncoderWithSchemaTestCase(BaseTestCase):
class SetOfEncoderTestCase(BaseTestCase):
def testEmpty(self):
s = univ.SetOf()
+ s.clear()
assert encoder.encode(s) == ints2octs((49, 128, 0, 0))
def testDefMode1(self):