1import pytest 2 3from cbor2.types import CBORTag, CBORSimpleValue 4 5 6def test_tag_repr(): 7 assert repr(CBORTag(600, 'blah')) == "CBORTag(600, 'blah')" 8 9 10def test_tag_equals(): 11 tag1 = CBORTag(500, ['foo']) 12 tag2 = CBORTag(500, ['foo']) 13 tag3 = CBORTag(500, ['bar']) 14 assert tag1 == tag2 15 assert not tag1 == tag3 16 assert not tag1 == 500 17 18 19def test_simple_value_repr(): 20 assert repr(CBORSimpleValue(1)) == "CBORSimpleValue(1)" 21 22 23def test_simple_value_equals(): 24 tag1 = CBORSimpleValue(1) 25 tag2 = CBORSimpleValue(1) 26 tag3 = CBORSimpleValue(21) 27 assert tag1 == tag2 28 assert tag1 == 1 29 assert not tag1 == tag3 30 assert not tag1 == 21 31 assert not tag2 == "21" 32 33 34def test_simple_value_too_big(): 35 exc = pytest.raises(TypeError, CBORSimpleValue, 256) 36 assert str(exc.value) == 'simple value too big' 37