MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_list_emulates

Method test_list_emulates

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

Source from the content-addressed store, hash-verified

680 self.assert_(getattr(ListLike, "_sa_instrumented") == id(ListLike))
681
682 def test_list_emulates(self):
683 class ListIsh:
684 __emulates__ = list
685
686 def __init__(self):
687 self.data = list()
688
689 def append(self, item):
690 self.data.append(item)
691
692 def remove(self, item):
693 self.data.remove(item)
694
695 def insert(self, index, item):
696 self.data.insert(index, item)
697
698 def pop(self, index=-1):
699 return self.data.pop(index)
700
701 def extend(self):
702 assert False
703
704 def __iter__(self):
705 return iter(self.data)
706
707 __hash__ = object.__hash__
708
709 def __eq__(self, other):
710 return self.data == other
711
712 def __repr__(self):
713 return "ListIsh(%s)" % repr(self.data)
714
715 self._test_adapter(ListIsh)
716 self._test_list(ListIsh)
717 self._test_list_bulk(ListIsh)
718 self.assert_(getattr(ListIsh, "_sa_instrumented") == id(ListIsh))
719
720 def _test_set_wo_mutation(self, typecallable, creator=None):
721 if creator is None:

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