aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2017-10-16 23:45:38 +0200
committerGitHub <noreply@github.com>2017-10-16 23:45:38 +0200
commitd1f9acd3859b7e40494bd619ab2e1c52dd72379c (patch)
treee4b24cff7c18da7461f12f773173fe539157e344 /tests
parente9371571a198af2c49151155f7a8ca9aa72580b9 (diff)
downloadpyasn1-d1f9acd3859b7e40494bd619ab2e1c52dd72379c.tar.gz
Remove None initializer support (#91)
* `None` legacy initializer support removed * Default value for `Null` removed
Diffstat (limited to 'tests')
-rw-r--r--tests/codec/ber/test_encoder.py8
-rw-r--r--tests/codec/native/test_decoder.py4
-rw-r--r--tests/type/test_univ.py24
3 files changed, 28 insertions, 8 deletions
diff --git a/tests/codec/ber/test_encoder.py b/tests/codec/ber/test_encoder.py
index ba91919..f87843c 100644
--- a/tests/codec/ber/test_encoder.py
+++ b/tests/codec/ber/test_encoder.py
@@ -746,11 +746,11 @@ class SequenceEncoderWithComponentsSchemaTestCase(BaseTestCase):
def __init(self):
self.s.clear()
- self.s.setComponentByPosition(0)
+ self.s.setComponentByPosition(0, '')
def __initWithOptional(self):
self.s.clear()
- self.s.setComponentByPosition(0)
+ self.s.setComponentByPosition(0, '')
self.s.setComponentByPosition(1, 'quick brown')
def __initWithDefaulted(self):
@@ -991,11 +991,11 @@ class SetEncoderWithComponentsSchemaTestCase(BaseTestCase):
def __init(self):
self.s.clear()
- self.s.setComponentByPosition(0)
+ self.s.setComponentByPosition(0, '')
def __initWithOptional(self):
self.s.clear()
- self.s.setComponentByPosition(0)
+ self.s.setComponentByPosition(0, '')
self.s.setComponentByPosition(1, 'quick brown')
def __initWithDefaulted(self):
diff --git a/tests/codec/native/test_decoder.py b/tests/codec/native/test_decoder.py
index c3854af..4eef69c 100644
--- a/tests/codec/native/test_decoder.py
+++ b/tests/codec/native/test_decoder.py
@@ -56,7 +56,7 @@ class OctetStringDecoderTestCase(BaseTestCase):
class NullDecoderTestCase(BaseTestCase):
def testNull(self):
- assert decoder.decode(None, asn1Spec=univ.Null()) == univ.Null()
+ assert decoder.decode(None, asn1Spec=univ.Null()) == univ.Null('')
class ObjectIdentifierDecoderTestCase(BaseTestCase):
@@ -83,7 +83,7 @@ class SequenceDecoderTestCase(BaseTestCase):
def testSimple(self):
s = self.s.clone()
- s[0] = univ.Null()
+ s[0] = univ.Null('')
s[1] = univ.OctetString('xx')
s[2] = univ.Integer(33)
assert decoder.decode({'place-holder': None, 'first-name': 'xx', 'age': 33}, asn1Spec=self.s) == s
diff --git a/tests/type/test_univ.py b/tests/type/test_univ.py
index f5124df..c40b512 100644
--- a/tests/type/test_univ.py
+++ b/tests/type/test_univ.py
@@ -546,11 +546,31 @@ class OctetStringTestCase(BaseTestCase):
class Null(BaseTestCase):
+
+ def testInit(self):
+ assert not univ.Null().isValue
+ assert univ.Null(0) == str2octs('')
+ assert univ.Null(False) == str2octs('')
+ assert univ.Null('') == str2octs('')
+ assert univ.Null(None) == str2octs('')
+
+ try:
+ assert univ.Null(True)
+
+ except PyAsn1Error:
+ pass
+
+ try:
+ assert univ.Null('xxx')
+
+ except PyAsn1Error:
+ pass
+
def testStr(self):
assert str(univ.Null('')) == '', 'str() fails'
def testRepr(self):
- assert eval(repr(univ.Null()), {'Null': univ.Null}) == univ.Null(), 'repr() fails'
+ assert eval(repr(univ.Null('')), {'Null': univ.Null}) == univ.Null(''), 'repr() fails'
def testTag(self):
assert univ.Null().tagSet == tag.TagSet(
@@ -571,7 +591,7 @@ class Null(BaseTestCase):
class Null(univ.Null):
pass
- assert not Null()
+ assert not Null('')
class RealTestCase(BaseTestCase):