def test_no_special_chars(self): self.assertEquals(Payload._truncate_json("", 100), "") self.assertEquals(Payload._truncate_json("big ", 100), "big ") self.assertTruncateList("big ", [ "", "b", "bi", "big", "big ", "big ", "big ", ])
def truncate_fun(content, length): truncated = Payload._truncate_json(content, length) escaped = Payload._to_json_utf8(truncated)[1:-1] return context[0] + escaped + context[1]