MCPcopy Index your code
hub / github.com/python/mypy / test_basic_cases

Method test_basic_cases

mypy/test/testinfer.py:218–248  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

216 return output
217
218 def test_basic_cases(self) -> None:
219 # Note: the grouping function doesn't actually inspect the input exprs, so we
220 # just default to using NameExprs for simplicity.
221 x0 = NameExpr("x0")
222 x1 = NameExpr("x1")
223 x2 = NameExpr("x2")
224 x3 = NameExpr("x3")
225 x4 = NameExpr("x4")
226
227 basic_input = [("==", x0, x1), ("==", x1, x2), ("<", x2, x3), ("==", x3, x4)]
228
229 none_assignable = self.literal_keymap({})
230 all_assignable = self.literal_keymap({0: x0, 1: x1, 2: x2, 3: x3, 4: x4})
231
232 for assignable in [none_assignable, all_assignable]:
233 self.assertEqual(
234 group_comparison_operands(basic_input, assignable, set()),
235 [("==", [0, 1]), ("==", [1, 2]), ("<", [2, 3]), ("==", [3, 4])],
236 )
237 self.assertEqual(
238 group_comparison_operands(basic_input, assignable, {"=="}),
239 [("==", [0, 1, 2]), ("<", [2, 3]), ("==", [3, 4])],
240 )
241 self.assertEqual(
242 group_comparison_operands(basic_input, assignable, {"<"}),
243 [("==", [0, 1]), ("==", [1, 2]), ("<", [2, 3]), ("==", [3, 4])],
244 )
245 self.assertEqual(
246 group_comparison_operands(basic_input, assignable, {"==", "<"}),
247 [("==", [0, 1, 2]), ("<", [2, 3]), ("==", [3, 4])],
248 )
249
250 def test_multiple_groups(self) -> None:
251 x0 = NameExpr("x0")

Callers

nothing calls this directly

Calls 4

literal_keymapMethod · 0.95
NameExprClass · 0.90
setClass · 0.85

Tested by

no test coverage detected