How to use the cbor2.types.CBORSimpleValue function in cbor2

To help you get started, we’ve selected a few cbor2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github agronholm / cbor2 / tests / test_types.py View on Github external
def test_simple_value_repr():
    assert repr(CBORSimpleValue(1)) == "CBORSimpleValue(1)"
github agronholm / cbor2 / tests / test_types.py View on Github external
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"
github agronholm / cbor2 / tests / test_types.py View on Github external
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"
github agronholm / cbor2 / tests / test_types.py View on Github external
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"
github agronholm / cbor2 / cbor2 / decoder.py View on Github external
def decode_special(self, subtype):
        # Simple value
        if subtype < 20:
            # XXX Set shareable?
            return CBORSimpleValue(subtype)

        # Major tag 7
        return special_decoders[subtype](self)
github agronholm / cbor2 / cbor2 / types.py View on Github external
def __ne__(self, other):
        if isinstance(other, CBORSimpleValue):
            return self.value != other.value
        elif isinstance(other, int):
            return self.value != other
        return NotImplemented
github agronholm / cbor2 / cbor2 / __init__.py View on Github external
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()
        ])