Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_simple_value_repr():
assert repr(CBORSimpleValue(1)) == "CBORSimpleValue(1)"
def test_simple_value_equals():
tag1 = CBORSimpleValue(1)
tag2 = CBORSimpleValue(1)
tag3 = CBORSimpleValue(21)
assert tag1 == tag2
assert tag1 == 1
assert not tag1 == tag3
assert not tag1 == 21
assert not tag2 == "21"
def test_simple_value_equals():
tag1 = CBORSimpleValue(1)
tag2 = CBORSimpleValue(1)
tag3 = CBORSimpleValue(21)
assert tag1 == tag2
assert tag1 == 1
assert not tag1 == tag3
assert not tag1 == 21
assert not tag2 == "21"
def test_simple_value_equals():
tag1 = CBORSimpleValue(1)
tag2 = CBORSimpleValue(1)
tag3 = CBORSimpleValue(21)
assert tag1 == tag2
assert tag1 == 1
assert not tag1 == tag3
assert not tag1 == 21
assert not tag2 == "21"
def decode_special(self, subtype):
# Simple value
if subtype < 20:
# XXX Set shareable?
return CBORSimpleValue(subtype)
# Major tag 7
return special_decoders[subtype](self)
def __ne__(self, other):
if isinstance(other, CBORSimpleValue):
return self.value != other.value
elif isinstance(other, int):
return self.value != other
return NotImplemented
from collections import OrderedDict
from .encoder import default_encoders, canonical_encoders
from .types import CBORTag, CBORSimpleValue, undefined # noqa
import _cbor2
_cbor2.default_encoders = OrderedDict([
((
_cbor2.CBORSimpleValue if type_ is CBORSimpleValue else
_cbor2.CBORTag if type_ is CBORTag else
type(_cbor2.undefined) if type_ is type(undefined) else
type_
), getattr(_cbor2.CBOREncoder, method.__name__))
for type_, method in default_encoders.items()
])
_cbor2.canonical_encoders = OrderedDict([
((
_cbor2.CBORSimpleValue if type_ is CBORSimpleValue else
_cbor2.CBORTag if type_ is CBORTag else
type(_cbor2.undefined) if type_ is type(undefined) else
type_
), getattr(_cbor2.CBOREncoder, method.__name__))
for type_, method in canonical_encoders.items()
])