MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_list_duck

Method test_list_duck

test/orm/test_collection.py:646–680  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

644 self.assert_(getattr(MyList, "_sa_instrumented") == id(MyList))
645
646 def test_list_duck(self):
647 class ListLike:
648 def __init__(self):
649 self.data = list()
650
651 def append(self, item):
652 self.data.append(item)
653
654 def remove(self, item):
655 self.data.remove(item)
656
657 def insert(self, index, item):
658 self.data.insert(index, item)
659
660 def pop(self, index=-1):
661 return self.data.pop(index)
662
663 def extend(self):
664 assert False
665
666 def __iter__(self):
667 return iter(self.data)
668
669 __hash__ = object.__hash__
670
671 def __eq__(self, other):
672 return self.data == other
673
674 def __repr__(self):
675 return "ListLike(%s)" % repr(self.data)
676
677 self._test_adapter(ListLike)
678 self._test_list(ListLike)
679 self._test_list_bulk(ListLike)
680 self.assert_(getattr(ListLike, "_sa_instrumented") == id(ListLike))
681
682 def test_list_emulates(self):
683 class ListIsh:

Callers

nothing calls this directly

Calls 4

_test_adapterMethod · 0.95
_test_listMethod · 0.95
_test_list_bulkMethod · 0.95
assert_Method · 0.45

Tested by

no test coverage detected