Skip to content

Commit 2fa5463

Browse files
authored
fix tests (#10)
1 parent 50235fa commit 2fa5463

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

Diff for: Lib/test/test_code.py

-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ def test_co_positions_artificial_instructions(self):
376376
for instruction in artificial_instructions
377377
],
378378
[
379-
('RESUME', 0),
380379
("PUSH_EXC_INFO", None),
381380
("LOAD_CONST", None), # artificial 'None'
382381
("STORE_NAME", "e"), # XX: we know the location for this

Diff for: Lib/test/test_compile.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_leading_newlines(self):
161161
co = compile(s256, 'fn', 'exec')
162162
self.assertEqual(co.co_firstlineno, 1)
163163
lines = list(co.co_lines())
164-
self.assertEqual(lines[0][2], None)
164+
self.assertEqual(lines[0][2], 0)
165165
self.assertEqual(lines[1][2], 257)
166166

167167
def test_literals_with_leading_zeroes(self):
@@ -1090,6 +1090,8 @@ def generic_visit(self, node):
10901090

10911091
# Check against the positions in the code object.
10921092
for (line, end_line, col, end_col) in code.co_positions():
1093+
if line == 0:
1094+
continue # This is an artificial module-start line
10931095
# If the offset is not None (indicating missing data), ensure that
10941096
# it was part of one of the AST nodes.
10951097
if line is not None:

Diff for: Lib/test/test_dis.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def bug42562():
267267
expr_str = "x + 1"
268268

269269
dis_expr_str = """\
270-
RESUME 0
270+
0 RESUME 0
271271
272272
1 LOAD_NAME 0 (x)
273273
LOAD_CONST 0 (1)
@@ -278,7 +278,7 @@ def bug42562():
278278
simple_stmt_str = "x = x + 1"
279279

280280
dis_simple_stmt_str = """\
281-
RESUME 0
281+
0 RESUME 0
282282
283283
1 LOAD_NAME 0 (x)
284284
LOAD_CONST 0 (1)
@@ -297,7 +297,7 @@ def bug42562():
297297
# leading newline is for a reason (tests lineno)
298298

299299
dis_annot_stmt_str = """\
300-
RESUME 0
300+
0 RESUME 0
301301
302302
2 SETUP_ANNOTATIONS
303303
LOAD_CONST 0 (1)
@@ -335,7 +335,7 @@ def bug42562():
335335
# Trailing newline has been deliberately omitted
336336

337337
dis_compound_stmt_str = """\
338-
RESUME 0
338+
0 RESUME 0
339339
340340
1 LOAD_CONST 0 (0)
341341
STORE_NAME 0 (x)
@@ -1092,7 +1092,7 @@ def test_super_instructions(self):
10921092
@cpython_only
10931093
def test_binary_specialize(self):
10941094
binary_op_quicken = """\
1095-
0 RESUME_QUICK 0
1095+
0 0 RESUME_QUICK 0
10961096
10971097
1 2 LOAD_NAME 0 (a)
10981098
4 LOAD_NAME 1 (b)
@@ -1110,7 +1110,7 @@ def test_binary_specialize(self):
11101110
self.do_disassembly_compare(got, binary_op_quicken % "BINARY_OP_ADD_UNICODE 0 (+)", True)
11111111

11121112
binary_subscr_quicken = """\
1113-
0 RESUME_QUICK 0
1113+
0 0 RESUME_QUICK 0
11141114
11151115
1 2 LOAD_NAME 0 (a)
11161116
4 LOAD_CONST 0 (0)
@@ -1130,7 +1130,7 @@ def test_binary_specialize(self):
11301130
@cpython_only
11311131
def test_load_attr_specialize(self):
11321132
load_attr_quicken = """\
1133-
0 RESUME_QUICK 0
1133+
0 0 RESUME_QUICK 0
11341134
11351135
1 2 LOAD_CONST 0 ('a')
11361136
4 LOAD_ATTR_SLOT 0 (__class__)
@@ -1144,7 +1144,7 @@ def test_load_attr_specialize(self):
11441144
@cpython_only
11451145
def test_call_specialize(self):
11461146
call_quicken = """\
1147-
RESUME_QUICK 0
1147+
0 RESUME_QUICK 0
11481148
11491149
1 PUSH_NULL
11501150
LOAD_NAME 0 (str)
@@ -1718,7 +1718,7 @@ def test_co_positions(self):
17181718
for instr in dis.get_instructions(code)
17191719
]
17201720
expected = [
1721-
(None, None, None, None),
1721+
(0, 1, 0, 0),
17221722
(1, 1, 0, 1),
17231723
(1, 1, 0, 1),
17241724
(2, 2, 2, 3),

0 commit comments

Comments
 (0)