def test_utils_markup_dumps(self): assert markup.dumps('123') == "'123'" expected = \ "[\n '123',\n 1,\n 1.1,\n {\n foo: []\n }\n]" expected = expected.replace(' ', '') assert markup.dumps(['123', 1, 1.1, { 'foo': () }]).replace(' ', '') == expected
def test_utils_markup_overflow_deep_1(self): obj = a = [] for _ in range(200): a.append([]) a = a[0] result = markup.dumps(obj).replace(' ', '').replace('\n', '') # current limit is 100, so 2 chars per list - 200 + some space reserved # for the OverflowBarier markup element # assert len(result) < 220
def test_utils_markup_overflow_wide(self): obj3 = [] for i in range(10): obj2 = [] for j in range(10): obj1 = [] for k in range(10): obj = [] for l in range(20): obj.append(list(1 for _ in range(10))) obj1.append(obj) obj2.append(obj1) obj3.append(obj2) result = markup.dumps(obj3).replace(' ', '').replace('\n', '') assert len(result) < 13000
def send_error(self, err): try: srcctx = exceptions.get_context(err, parsing.ParserContext) except LookupError: srcctx = None try: hintctx = exceptions.get_context( err, exceptions.DefaultExceptionContext) except LookupError: hintctx = None if debug.flags.server: debug.header('Error') debug.dump(err) self.send_message({ '__type__': 'error', 'data': { 'C': getattr(err, 'code', 0), 'M': str(err), 'D': hintctx.details if hintctx is not None else None, 'H': hintctx.hint if hintctx is not None else None, 'P': (srcctx.start.pointer if srcctx is not None and srcctx.start is not None else None), 'p': (srcctx.end.pointer if srcctx is not None and srcctx.end is not None else None), 'Q': markup.dumps(srcctx) if srcctx is not None else None, 'T': traceback.format_tb(err.__traceback__), } })
def test_utils_markup_dump_ordereddict(self): obj = collections.OrderedDict([[1, 2], [2, 3], [3, 4], [5, 6]]) result = ''.join(markup.dumps(obj).split()) assert result == '{1:2,2:3,3:4,5:6}'