Esempio n. 1
0
    def _fn(msg, minver=0x0200, exclude=None):

        out = []
        fp = BytesIO()
        rstream = ReadStream(fp)

        if codec.proto_rev < minver:
            # The codec won't have the correct struct set if
            # the version isn't supported
            Message.write(msg, out, codec)
            assert not out
            return

        Message.write(msg, out, codec)
        fp.write(b"".join(out))
        fp.seek(0)

        mm = Message.read(rstream, codec, lambda x: msg.value.type)

        with pytest.raises(StreamEOF):
            rstream.read(1)

        # In v2, some fields aren't copied over, so we exclude them
        # by overwriting those indices and recreating the read message
        if exclude:
            args = list(mm)
            for e in exclude:
                args[e] = msg[e]
            mm = MessageType(*args)

        assert msg == mm
Esempio n. 2
0
 def _fn(msg, minver=0x0200, exclude=None):
     
     out = []
     fp = BytesIO()
     rstream = ReadStream(fp)
     
     if codec.proto_rev < minver:
         # The codec won't have the correct struct set if
         # the version isn't supported
         Message.write(msg, out, codec)
         assert not out
         return
     
     Message.write(msg, out, codec)
     fp.write(b''.join(out))
     fp.seek(0)
     
     mm = Message.read(rstream, codec, lambda x: msg.value.type)
   
     with pytest.raises(StreamEOF):
         rstream.read(1)
     
     # In v2, some fields aren't copied over, so we exclude them
     # by overwriting those indices and recreating the read message
     if exclude:
         args = list(mm)
         for e in exclude:
             args[e] = msg[e]
         mm = MessageType(*args)
     
     assert msg == mm