def ok_response(self, response): self.set_header('Content-Type', 'application/json') msg = { 'stat': 'OK', # Make sure there aren't any bytestrings in response, # as those aren't JSONizable. 'response': recursive_unicode(response) } # buf = strutil.enc_json(msg) # self.finish(buf) self.write(msg)
def test_recursive_unicode(self): self.assertEqual(recursive_unicode("rawr"), u"rawr") self.assertEqual(recursive_unicode({"rawr": "rawr"}), {"rawr": u"rawr"}) self.assertEqual(recursive_unicode(["rawr", "rawr"]), [u"rawr", u"rawr"])
def test_recursive_unicode(self): self.assertEqual(recursive_unicode("rawr"), u"rawr") self.assertEqual( recursive_unicode({"rawr": "rawr"}), {"rawr": u"rawr"}) self.assertEqual( recursive_unicode(["rawr", "rawr"]), [u"rawr", u"rawr"])