summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2019-08-25 14:35:44 +0200
committerGitHub <noreply@github.com>2019-08-25 14:35:44 +0200
commit66afc8921e4f5d3a41e407ab6d95ce7e4ec5383a (patch)
treee552f03ee7846566b4b036c192d9ed326a9e74a5 /tests
parentec580e545ef25f117573014d40ca5c512e58dbf3 (diff)
downloadpyasn1-git-66afc8921e4f5d3a41e407ab6d95ce7e4ec5383a.tar.gz
Add `isInconsistent` property hook to all constructed types (#170)
Added `isInconsistent` property to all constructed types. This property conceptually replaces `verifySizeSpec` method to serve a more general purpose e.g. ensuring all required fields are in a good shape. By default this check invokes subtype constraints verification and is run by codecs on value de/serialisation.
Diffstat (limited to 'tests')
-rw-r--r--tests/type/test_univ.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/tests/type/test_univ.py b/tests/type/test_univ.py
index 0092588..4cbfa01 100644
--- a/tests/type/test_univ.py
+++ b/tests/type/test_univ.py
@@ -1040,22 +1040,14 @@ class SequenceOf(BaseTestCase):
else:
pass
- def testSizeSpec(self):
+ def testConsistency(self):
s = self.s1.clone(sizeSpec=constraint.ConstraintsUnion(
constraint.ValueSizeConstraint(1, 1)
))
s.setComponentByPosition(0, univ.OctetString('abc'))
- try:
- s.verifySizeSpec()
- except PyAsn1Error:
- assert 0, 'size spec fails'
+ assert not s.isInconsistent, 'size spec fails'
s.setComponentByPosition(1, univ.OctetString('abc'))
- try:
- s.verifySizeSpec()
- except PyAsn1Error:
- pass
- else:
- assert 0, 'size spec fails'
+ assert s.isInconsistent, 'size spec fails'
def testGetComponentTagMap(self):
assert self.s1.componentType.tagMap.presentTypes == {