MCPcopy
hub / github.com/rocky/python-uncompyle6 / check_expect

Function check_expect

pytest/test_deparse.py:35–73  ·  view source on GitHub ↗
(expect, parsed, fn_name)

Source from the content-addressed store, hash-verified

33 return deparse(code, version=PYTHON_VERSION_TRIPLE)
34
35def check_expect(expect, parsed, fn_name):
36 debug = False
37 i = 2
38 max_expect = len(expect)
39 for name, offset in sorted(parsed.offsets.keys()):
40 assert i+1 <= max_expect, (
41 "%s: ran out if items in testing node" % fn_name)
42 nodeInfo = parsed.offsets[name, offset]
43 node = nodeInfo.node
44 extractInfo = parsed.extract_node_info(node)
45
46 assert expect[i] == extractInfo.selectedLine, \
47 ('%s: line %s expect:\n%s\ngot:\n%s' %
48 (fn_name, i, expect[i], extractInfo.selectedLine))
49 assert expect[i+1] == extractInfo.markerLine, \
50 ('line %s expect:\n%s\ngot:\n%s' %
51 (i+1, expect[i+1], extractInfo.markerLine))
52 i += 3
53 if debug:
54 print(node.offset)
55 print(extractInfo.selectedLine)
56 print(extractInfo.markerLine)
57
58 extractInfo, p = parsed.extract_parent_info(node)
59 if extractInfo:
60 assert i+1 < max_expect, "ran out of items in testing parent"
61 if debug:
62 print("Contained in...")
63 print(extractInfo.selectedLine)
64 print(extractInfo.markerLine)
65 assert expect[i] == extractInfo.selectedLine, \
66 ("parent line %s expect:\n%s\ngot:\n%s" %
67 (i, expect[i], extractInfo.selectedLine))
68 assert expect[i+1] == extractInfo.markerLine, \
69 ("parent line %s expect:\n%s\ngot:\n%s" %
70 (i+1, expect[i+1], extractInfo.markerLine))
71 i += 3
72 pass
73 pass
74
75
76def test_stuff():

Callers 1

test_stuffFunction · 0.85

Calls 3

extract_node_infoMethod · 0.80
extract_parent_infoMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected