def test_delete_option(): opts = Options() opts.field_names = {'comment': 0x0001, 'example': 0xff02} opts.add_value('comment', 'Hello world') opts.add_value('comment', 'This is another comment') assert opts.pack(endianness=1) == ( "\x01\x00\x0B\x00Hello world\x00" "\x01\x00\x17\x00This is another comment\x00" "\x00\x00\x00\x00") del opts['comment'] assert opts.pack(endianness=1) == "\x00\x00\x00\x00"
def test_create_handcrafted_1(): opts = Options() opts.field_names = {'comment': 0x0001, 'example': 0xff02} opts.add_value('comment', 'Hello world') opts.add_value('comment', 'This is another comment') opts.add_value('example', 'Example value') assert opts.pack(endianness=1) == HANDCRAFTED_OPTIONS[1]