Ejemplo n.º 1
0
def test_unicode_atom_encode_raises():
    # ATM, we only allow packing latin-1 encoded Atoms because the underlying
    # library sends ATOM_EXT instead of ATOM_UTF8_EXT. Update this test when
    # we are ready to start sending UTF-8 atoms.
    atm = Atom(u'こんにちは世界')  # hello world
    try:
        pack(atm)
        raise Exception('did not raise UnicodeEncodeError')
    except UnicodeEncodeError:
        pass
Ejemplo n.º 2
0
def test_unpack_kitchen_sink():
    assert unpack('\x83l\x00\x00\x00\x0cd\x00\x08someatomh\x03d\x00\x04somed\x00\x05otherm\x00\x00\x00\x05tuplel\x00\x00\x00\x03m\x00\x00\x00\x05maybea\x01jjh\x03m\x00\x00\x00\x04withh\x02d\x00\x08embeddedl\x00\x00\x00\x01m\x00\x00\x00\x10tuples and listsjd\x00\x03niln\x08\x00\x90gWs\x1f\x1f\xc5\x01F@\xb4\xd6Q\xeb\x85\x1e\xb8afb\xff\xff\xfa\x8eF\xc0u\xd333333n\x05\x01ch\t\ntl\x00\x00\x00\x02t\x00\x00\x00\x03d\x00\x01am\x00\x00\x00\x03mapd\x00\x04alsoh\x03m\x00\x00\x00\x06tuplesl\x00\x00\x00\x01m\x00\x00\x00\x03andjl\x00\x00\x00\x01m\x00\x00\x00\x05listsjd\x00\x04withm\x00\x00\x00\x08binariest\x00\x00\x00\x02a\x03m\x00\x00\x00\x08int keysd\x00\x01am\x00\x00\x00\nanotheronejt\x00\x00\x00\x01h\x01d\x00\tsomethingm\x00\x00\x00\x04elsej') == [Atom('someatom'), (Atom('some'), Atom('other'), 'tuple'), ['maybe', 1, []], ('with', (Atom('embedded'), ['tuples and lists']), None), 127542384389482384L, 5334.32, 102, -1394, -349.2, -498384595043, [{Atom('a'): 'map', Atom('also'): ('tuples', ['and'], ['lists']), Atom('with'): 'binaries'}, {Atom('a'): 'anotherone', 3: 'int keys'}], {(Atom('something'),): 'else'}]
Ejemplo n.º 3
0
def test_unpack_basic_atom():
    assert unpack('\x83d\x00\x02hi') == Atom('hi')
Ejemplo n.º 4
0
def test_pack_basic_atom():
    assert pack(Atom('hi')) == '\x83s\x02hi'
Ejemplo n.º 5
0
def test_unicode_atom_decodes():
    atm = unpack(
        b'\x83w\x15\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf\xe4\xb8\x96\xe7\x95\x8c'
    )
    assert atm == Atom(u'こんにちは世界')