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

Method _fixture

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

Source from the content-addressed store, hash-verified

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