MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _fixture

Method _fixture

test/orm/test_composites.py:789–846  ·  test/orm/test_composites.py::NestedTest._fixture
(self)

Source from the content-addressed store, hash-verified

787 )
788
789 def _fixture(self):
790 class AB:
791 def __init__(self, a, b, cd):
792 self.a = a
793 self.b = b
794 self.cd = cd
795
796 @classmethod
797 def generate(cls, a, b, c, d):
798 return AB(a, b, CD(c, d))
799
800 def __composite_values__(self):
801 return (self.a, self.b) + self.cd.__composite_values__()
802
803 def __eq__(self, other):
804 return (
805 isinstance(other, AB)
806 and self.a == other.a
807 and self.b == other.b
808 and self.cd == other.cd
809 )
810
811 def __ne__(self, other):
812 return not self.__eq__(other)
813
814 class CD:
815 def __init__(self, c, d):
816 self.c = c
817 self.d = d
818
819 def __composite_values__(self):
820 return (self.c, self.d)
821
822 def __eq__(self, other):
823 return (
824 isinstance(other, CD)
825 and self.c == other.c
826 and self.d == other.d
827 )
828
829 def __ne__(self, other):
830 return not self.__eq__(other)
831
832 class Thing:
833 def __init__(self, ab):
834 self.ab = ab
835
836 stuff = self.tables.stuff
837 self.mapper_registry.map_imperatively(
838 Thing,
839 stuff,
840 properties={
841 class="st">"ab": composite(
842 AB.generate, stuff.c.a, stuff.c.b, stuff.c.c, stuff.c.d
843 )
844 },
845 )
846 return Thing, AB, CD

Callers 1

test_round_tripMethod · 0.95

Calls 2

compositeFunction · 0.90
map_imperativelyMethod · 0.80

Tested by

no test coverage detected