Skip to content

Commit 76447b0

Browse files
committed
more missing test cases
1 parent 8842b91 commit 76447b0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/unit/transformer/test_node_transformer.py

+21
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class TestNodeTransformer:
5050
("a + b", "BinOp", 1),
5151
("a or b", "BoolOp", 1),
5252
("[1,2]", "List", 1),
53+
# set is xfailing right now
5354
# ("{1,2}", "Set", 1),
5455
# tuple eventually calls tracer.call but we've mocked out the whole thing
5556
("(1,2)", "Tuple", 0),
@@ -59,6 +60,15 @@ class TestNodeTransformer:
5960
("fn(*args)", "Call", 1),
6061
("fn(*args)", "Starred", 1),
6162
("fn(*args)", "Name", 1),
63+
("print(*'mystring')", "Starred", 1),
64+
# calls tracer.trace_import but this list checks for tracer.call calls
65+
("import math", "Import", 0),
66+
# calls tracer.trace_import but this list checks for tracer.call calls
67+
# TODO - import from calls transform utils which should really be mocked out and
68+
# tested on their own, in true spirit of unit testing
69+
("from math import sqrt", "ImportFrom", 0),
70+
("a, b = (1,2)", "Assign", 2),
71+
("lambda x: x + 10", "Lambda", 1),
6272
]
6373

6474
# TODO pull out constant to handle 3.7 vs 3.9 etc
@@ -83,15 +93,26 @@ class TestNodeTransformer:
8393
"call",
8494
"starred",
8595
"name",
96+
"starred_str",
97+
"import",
98+
"import_from",
99+
"assign_tuple",
100+
"lambda",
86101
]
87102

88103
if sys.version_info < (3, 8):
89104
basic_tests_list += (("10", "Num", 0),)
105+
# extslice does not call tracer.call but it contains a slice node.
106+
# that along with subscript will result in two calls
107+
basic_tests_list += (("a[:,3]", "ExtSlice", 2),)
90108
basic_test_ids += ["num"]
109+
basic_test_ids += ["extslice"]
91110
else:
92111
# this will break with 3.7
93112
basic_tests_list += (("10", "Constant", 0),)
113+
basic_tests_list += (("a[:,3]", "Slice", 2),)
94114
basic_test_ids += ["constant"]
115+
basic_test_ids += ["slice_with_ext"]
95116

96117
basic_tests = ("code, visitor, call_count", basic_tests_list)
97118

0 commit comments

Comments
 (0)