def __runtest(library): original_lib = util.get_json_lib() self._setlib(library) try: text2 = util.json_encode(obj) self.assertEquals(text, text2) obj2 = util.json_decode(text2) text3 = util.json_encode(obj2) self.assertEquals(text, text3) finally: util._set_json_lib(original_lib)
def _setlib(self, library): if library == JSON: util._set_json_lib("json") elif library == UJSON: util._set_json_lib("ujson") else: util._set_json_lib("json_lib")
def _setlib(self, library): if library == JSON: util._set_json_lib('json') elif library == UJSON: util._set_json_lib('ujson') else: util._set_json_lib('json_lib')
def _setlib(self, library): if library == JSON: util._set_json_lib('json') elif library == UJSON: util._set_json_lib('ujson') else: util._set_json_lib('json_lib')
def test_invalid_lib(self): self.assertRaises(ValueError, lambda: util._set_json_lib("BAD JSON LIBRARY NAME"))
def test_invalid_lib(self): self.assertRaises(ValueError, lambda: util._set_json_lib('BAD JSON LIBRARY NAME'))
def test_invalid_lib(self): with self.assertRaises(ValueError): util._set_json_lib('BAD JSON LIBRARY NAME')