Example #1
0
    def do_test(self):
        self._check_write(HolyMoley())
        self._check_read(HolyMoley())

        self._check_write(hm)
        no_set = deepcopy(hm)
        no_set.contain = set()
        self._check_read(no_set)
        self._check_read(hm)

        self._check_write(rs)
        self._check_read(rs)

        self._check_write(rshuge)
        self._check_read(rshuge)

        self._check_write(my_zero)
        self._check_read(my_zero)

        self._check_read(Backwards(**{"first_tag2": 4, "second_tag1": 2}))


        o = Backwards(**{"first_tag2": 4, "second_tag1": 2})
        trans_fast = TTransport.TMemoryBuffer()
        trans_slow = TTransport.TMemoryBuffer()
        prot_fast = self._fast(trans_fast, fallback=False)
        prot_slow = self._slow(trans_slow)

        o.write(prot_fast)
        o.write(prot_slow)
        ORIG = trans_slow.getvalue()
        MINE = trans_fast.getvalue()
        assert id(ORIG) != id(MINE)

        prot = self._fast(TTransport.TMemoryBuffer(), fallback=False)
        o.write(prot)
        prot = self._slow(
            TTransport.TMemoryBuffer(prot.trans.getvalue()))
        c = o.__class__()
        c.read(prot)
        if c != o:
            print("copy: ")
            pprint(repr(c))
            print("orig: ")
            pprint(repr(o))
Example #2
0
def do_test():
    check_write(hm)
    check_read(HolyMoley())
    no_set = deepcopy(hm)
    no_set.contain = set()
    check_read(no_set)
    check_write(rs)
    check_read(rs)
    check_write(rshuge)
    check_read(rshuge)
    check_write(my_zero)
    check_read(my_zero)
    check_read(Backwards(**{"first_tag2": 4, "second_tag1": 2}))

    # One case where the serialized form changes, but only superficially.
    o = Backwards(**{"first_tag2": 4, "second_tag1": 2})
    trans_fast = TTransport.TMemoryBuffer()
    trans_slow = TTransport.TMemoryBuffer()
    prot_fast = TBinaryProtocol.TBinaryProtocolAccelerated(trans_fast)
    prot_slow = TBinaryProtocol.TBinaryProtocol(trans_slow)

    o.write(prot_fast)
    o.write(prot_slow)
    ORIG = trans_slow.getvalue()
    MINE = trans_fast.getvalue()
    assert id(ORIG) != id(MINE)

    prot = TBinaryProtocol.TBinaryProtocolAccelerated(
        TTransport.TMemoryBuffer())
    o.write(prot)
    prot = TBinaryProtocol.TBinaryProtocol(
        TTransport.TMemoryBuffer(prot.trans.getvalue()))
    c = o.__class__()
    c.read(prot)
    if c != o:
        print("copy: ")
        pprint(eval(repr(c)))
        print("orig: ")
        pprint(eval(repr(o)))
Example #3
0
    def do_test(self):
        self._check_write(HolyMoley())
        self._check_read(HolyMoley())

        self._check_write(hm)
        no_set = deepcopy(hm)
        no_set.contain = set()
        self._check_read(no_set)
        self._check_read(hm)

        self._check_write(rs)
        self._check_read(rs)

        self._check_write(rshuge)
        self._check_read(rshuge)

        self._check_write(my_zero)
        self._check_read(my_zero)

        self._check_read(Backwards(**{"first_tag2": 4, "second_tag1": 2}))

        # One case where the serialized form changes, but only superficially.
        o = Backwards(**{"first_tag2": 4, "second_tag1": 2})
        trans_fast = TTransport.TMemoryBuffer()
        trans_slow = TTransport.TMemoryBuffer()
        prot_fast = self._fast(trans_fast, fallback=False)
        prot_slow = self._slow(trans_slow)

        o.write(prot_fast)
        o.write(prot_slow)
        ORIG = trans_slow.getvalue()
        MINE = trans_fast.getvalue()
        assert id(ORIG) != id(MINE)

        prot = self._fast(TTransport.TMemoryBuffer(), fallback=False)
        o.write(prot)
        prot = self._slow(
            TTransport.TMemoryBuffer(prot.trans.getvalue()))
        c = o.__class__()
        c.read(prot)
        if c != o:
            print("copy: ")
            pprint(repr(c))
            print("orig: ")
            pprint(repr(o))
Example #4
0
def do_test():
    check_write(hm)
    check_read(HolyMoley())
    no_set = deepcopy(hm)
    no_set.contain = set()
    check_read(no_set)
    check_write(rs)
    check_read(rs)
    check_write(rshuge)
    check_read(rshuge)
    check_write(my_zero)
    check_read(my_zero)
    check_read(Backwards(**{"first_tag2": 4, "second_tag1": 2}))

    # One case where the serialized form changes, but only superficially.
    o = Backwards(**{"first_tag2": 4, "second_tag1": 2})
    trans_fast = TTransport.TMemoryBuffer()
    trans_slow = TTransport.TMemoryBuffer()
    prot_fast = TBinaryProtocol.TBinaryProtocolAccelerated(trans_fast)
    prot_slow = TBinaryProtocol.TBinaryProtocol(trans_slow)

    o.write(prot_fast)
    o.write(prot_slow)
    ORIG = trans_slow.getvalue()
    MINE = trans_fast.getvalue()
    assert id(ORIG) != id(MINE)

    prot = TBinaryProtocol.TBinaryProtocolAccelerated(TTransport.TMemoryBuffer())
    o.write(prot)
    prot = TBinaryProtocol.TBinaryProtocol(
        TTransport.TMemoryBuffer(prot.trans.getvalue()))
    c = o.__class__()
    c.read(prot)
    if c != o:
        print("copy: ")
        pprint(eval(repr(c)))
        print("orig: ")
        pprint(eval(repr(o)))