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

Method test_inplace

Lib/test/test_operator.py:514–545  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

512 self.assertEqual(f(a), (many_positional_arguments, many_kw_arguments))
513
514 def test_inplace(self):
515 operator = self.module
516 class C(object):
517 def __iadd__ (self, other): return "iadd"
518 def __iand__ (self, other): return "iand"
519 def __ifloordiv__(self, other): return "ifloordiv"
520 def __ilshift__ (self, other): return "ilshift"
521 def __imod__ (self, other): return "imod"
522 def __imul__ (self, other): return "imul"
523 def __imatmul__ (self, other): return "imatmul"
524 def __ior__ (self, other): return "ior"
525 def __ipow__ (self, other): return "ipow"
526 def __irshift__ (self, other): return "irshift"
527 def __isub__ (self, other): return "isub"
528 def __itruediv__ (self, other): return "itruediv"
529 def __ixor__ (self, other): return "ixor"
530 def __getitem__(self, other): return 5 # so that C is a sequence
531 c = C()
532 self.assertEqual(operator.iadd (c, 5), "iadd")
533 self.assertEqual(operator.iand (c, 5), "iand")
534 self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv")
535 self.assertEqual(operator.ilshift (c, 5), "ilshift")
536 self.assertEqual(operator.imod (c, 5), "imod")
537 self.assertEqual(operator.imul (c, 5), "imul")
538 self.assertEqual(operator.imatmul (c, 5), "imatmul")
539 self.assertEqual(operator.ior (c, 5), "ior")
540 self.assertEqual(operator.ipow (c, 5), "ipow")
541 self.assertEqual(operator.irshift (c, 5), "irshift")
542 self.assertEqual(operator.isub (c, 5), "isub")
543 self.assertEqual(operator.itruediv (c, 5), "itruediv")
544 self.assertEqual(operator.ixor (c, 5), "ixor")
545 self.assertEqual(operator.iconcat (c, c), "iadd")
546
547 def test_iconcat_without_getitem(self):
548 operator = self.module

Callers

nothing calls this directly

Calls 6

iaddMethod · 0.80
imulMethod · 0.80
itruedivMethod · 0.80
iconcatMethod · 0.80
CClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected