test #8133
(self, registry, connection, pickleit)
| 159 | class MiscTest(fixtures.TestBase): |
| 160 | @testing.combinations(True, False, argnames=class="st">"pickleit") |
| 161 | def test_pickle_parent_multi_attrs(self, registry, connection, pickleit): |
| 162 | class="st">""class="st">"test class="cm">#8133"class="st">"" |
| 163 | |
| 164 | local_foo = Table( |
| 165 | class="st">"lf", |
| 166 | registry.metadata, |
| 167 | Column(class="st">"id", Integer, primary_key=True), |
| 168 | Column(class="st">"j1", MutableDict.as_mutable(PickleType)), |
| 169 | Column(class="st">"j2", MutableDict.as_mutable(PickleType)), |
| 170 | Column(class="st">"j3", MutableDict.as_mutable(PickleType)), |
| 171 | Column(class="st">"j4", MutableDict.as_mutable(PickleType)), |
| 172 | ) |
| 173 | |
| 174 | registry.map_imperatively(Foo2, local_foo) |
| 175 | registry.metadata.create_all(connection) |
| 176 | |
| 177 | with Session(connection) as sess: |
| 178 | data = dict( |
| 179 | j1={class="st">"a": 1}, |
| 180 | j2={class="st">"b": 2}, |
| 181 | j3={class="st">"c": 3}, |
| 182 | j4={class="st">"d": 4}, |
| 183 | ) |
| 184 | lf = Foo2(**data) |
| 185 | sess.add(lf) |
| 186 | sess.commit() |
| 187 | |
| 188 | all_attrs = {class="st">"j1", class="st">"j2", class="st">"j3", class="st">"j4"} |
| 189 | for attr in all_attrs: |
| 190 | for loads, dumps in picklers(): |
| 191 | with Session(connection) as sess: |
| 192 | f1 = sess.scalars(select(Foo2)).first() |
| 193 | if pickleit: |
| 194 | f2 = loads(dumps(f1)) |
| 195 | else: |
| 196 | f2 = f1 |
| 197 | |
| 198 | existing_dict = getattr(f2, attr) |
| 199 | existing_dict[class="st">"q"] = class="st">"c" |
| 200 | eq_( |
| 201 | inspect(f2).attrs[attr].history, |
| 202 | ([existing_dict], (), ()), |
| 203 | ) |
| 204 | for other_attr in all_attrs.difference([attr]): |
| 205 | a = inspect(f2).attrs[other_attr].history |
| 206 | b = ((), [data[other_attr]], ()) |
| 207 | eq_(a, b) |
| 208 | |
| 209 | @testing.combinations(class="st">"key_present", class="st">"key_non_present", argnames=class="st">"present") |
| 210 | @testing.combinations( |
nothing calls this directly
no test coverage detected