MCPcopy Index your code
hub / github.com/python/cpython / test_expressions

Method test_expressions

Lib/test/test_annotationlib.py:268–330  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

266 self.assertEqual(anno, {"x": "int", "y": "doesntexist"})
267
268 def test_expressions(self):
269 def f(
270 add: a + b,
271 sub: a - b,
272 mul: a * b,
273 matmul: a @ b,
274 truediv: a / b,
275 mod: a % b,
276 lshift: a << b,
277 rshift: a >> b,
278 or_: a | b,
279 xor: a ^ b,
280 and_: a & b,
281 floordiv: a // b,
282 pow_: a**b,
283 lt: a < b,
284 le: a <= b,
285 eq: a == b,
286 ne: a != b,
287 gt: a > b,
288 ge: a >= b,
289 invert: ~a,
290 neg: -a,
291 pos: +a,
292 getitem: a[b],
293 getattr: a.b,
294 call: a(b, *c, d=e), # **kwargs are not supported
295 *args: *a,
296 ):
297 pass
298
299 anno = get_annotations(f, format=Format.STRING)
300 self.assertEqual(
301 anno,
302 {
303 "add": "a + b",
304 "sub": "a - b",
305 "mul": "a * b",
306 "matmul": "a @ b",
307 "truediv": "a / b",
308 "mod": "a % b",
309 "lshift": "a << b",
310 "rshift": "a >> b",
311 "or_": "a | b",
312 "xor": "a ^ b",
313 "and_": "a & b",
314 "floordiv": "a // b",
315 "pow_": "a ** b",
316 "lt": "a < b",
317 "le": "a <= b",
318 "eq": "a == b",
319 "ne": "a != b",
320 "gt": "a > b",
321 "ge": "a >= b",
322 "invert": "~a",
323 "neg": "-a",
324 "pos": "+a",
325 "getitem": "a[b]",

Callers

nothing calls this directly

Calls 2

get_annotationsFunction · 0.90
assertEqualMethod · 0.45

Tested by

no test coverage detected