Exemple #1
0
def test_invalid_characters():
    try:
        deserialize(b'i1@34$')
    except DeserializationError:
        pass
    else:
        assert False
Exemple #2
0
def test_no_separator():
    try:
        deserialize(b'i1i2s3')
    except DeserializationError:
        pass
    else:
        assert False
Exemple #3
0
def test_too_long_integer():
    try:
        a = deserialize(b'i' + b'6' * (10**6))
    except DeserializationError:
        pass
    else:
        assert False
Exemple #4
0
def test_invalid_starting_character():
    try:
        i = deserialize(b'00000')
    except DeserializationError:
        pass
    else:
        print(i)
        assert False
Exemple #5
0
    def onGotPacket(self, packet, addr):
        if packet == '':
            return

        try:
            operands = deserialize(packet)
        except DeserializationError:
            print("Got malformed packet: " + repr(packet))
            return

        (opcode, operands) = (operands[0], operands[1:])

        key = self.tryFindKey(opcode)

        decoded_args = rep.decode_args_from_client(key, operands, self.player_for_addr(addr))

        if self.verbose:
            log_recv_from_client(key, operands, decoded_args)

        self.tryCall(key, [addr] + list(decoded_args))
Exemple #6
0
def test_bools():
    lst = [False, True, False]
    assert lst == deserialize(serialize(lst))
Exemple #7
0
def test_sanity_check():
    deserialize(serialize([135, True, 'abc']))