def test_limit(self): stream = BytesIO() record = Record('unknown', '', 0x100000 * b'\0') octets = bytearray.fromhex('050000100000') + 0x100000 * b'\0' assert record._encode(stream=stream) == len(octets) assert stream.getvalue() == octets record = Record('unknown', '', 0x100001 * b'\0') errstr = "payload of more than 1048576 octets can not be encoded" with pytest.raises(ndef.EncodeError) as excinfo: record._encode(stream=stream) assert str(excinfo.value) == 'ndef.record.Record ' + errstr
def test_pass(self, args, encoded): stream = BytesIO() record = Record(*args) octets = bytearray.fromhex(encoded) assert record._encode(stream=stream) == len(octets) assert stream.getvalue() == octets