MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / _fixture

Method _fixture

test/ext/test_associationproxy.py:118–155  ·  view source on GitHub ↗
(self, collection_class, is_dict=False)

Source from the content-addressed store, hash-verified

116 )
117
118 def _fixture(self, collection_class, is_dict=False):
119 class Parent:
120 collection = association_proxy("_collection", "child")
121
122 class Child:
123 def __init__(self, name):
124 self.name = name
125
126 class Association:
127 if is_dict:
128
129 def __init__(self, key, child):
130 self.child = child
131
132 else:
133
134 def __init__(self, child):
135 self.child = child
136
137 self.mapper_registry.map_imperatively(
138 Parent,
139 self.tables.parent,
140 properties={
141 "_collection": relationship(
142 Association,
143 collection_class=collection_class,
144 backref="parent",
145 )
146 },
147 )
148 self.mapper_registry.map_imperatively(
149 Association,
150 self.tables.association,
151 properties={"child": relationship(Child, backref="association")},
152 )
153 self.mapper_registry.map_imperatively(Child, self.tables.child)
154
155 return Parent, Child, Association
156
157 def _test_premature_flush(self, collection_class, fn, is_dict=False):
158 Parent, Child, Association = self._fixture(

Callers 1

_test_premature_flushMethod · 0.95

Calls 2

relationshipFunction · 0.90
map_imperativelyMethod · 0.80

Tested by

no test coverage detected