Example #1
0
 def decode_map_length(self, ch):
     if self.decode_int_value(ch):
         self.stack[-1].is_mapping = 1
         self.init_collection(Object())
Example #2
0
#client.....
#print "-"*60
neg = NegotiationClient(["Packed", "XML"])
test("", result_str="ATLAS client\n")
test("ATLAS server hi there\n", result_str="ICAN Packed\nICAN XML\n\n")
test("IWILL Packed\n\n", result="found", codec="Packed")
assert (neg.other_codecs == ['Packed'])

#client.....
#print "-"*60
neg = NegotiationClient(["X-foo"])
test("", result_str="ATLAS client\n")
test("ATLAS server hi there\n", result_str="ICAN X-foo\n\n")
test("ICAN Packed\nICAN XML\n\n", result="fail")
assert (neg.other_codecs == ['Packed', 'XML'])

neg = NegotiationClient()
test(
    "ATLAS server hi there\n",
    result_str=
    "ATLAS client\nICAN Bach_beta2\nICAN XML\nICAN XML2_test\nICAN Packed\nICAN Binary1_beta\nICAN Binary2_test\n\n"
)
test("IWILL XML\n\n", result="found", codec="XML")
co = neg.get_codec()
s = co.encode(Object(foo=42)) + co.encoder.close()
assert (s ==
        '<atlas>\n\t<map>\n\t\t<int name="foo">42</int>\n\t</map>\n</atlas>\n')
assert (co.decode("<atlas>") == [])
assert (co.decode(s) == [Object(foo=42)])
Example #3
0
 def start_map(self):
     self.start_value("none")
     self.push_value(Object())