(self, typecallable, creator=None)
| 1202 | self.assert_(getattr(SetIsh, "_sa_instrumented") == id(SetIsh)) |
| 1203 | |
| 1204 | def _test_dict_wo_mutation(self, typecallable, creator=None): |
| 1205 | if creator is None: |
| 1206 | creator = self.dictable_entity |
| 1207 | |
| 1208 | class Foo: |
| 1209 | pass |
| 1210 | |
| 1211 | canary = Canary() |
| 1212 | instrumentation.register_class(Foo) |
| 1213 | d = _register_attribute( |
| 1214 | Foo, |
| 1215 | "attr", |
| 1216 | uselist=True, |
| 1217 | typecallable=typecallable, |
| 1218 | useobject=True, |
| 1219 | ) |
| 1220 | canary.listen(d) |
| 1221 | |
| 1222 | obj = Foo() |
| 1223 | |
| 1224 | e = creator() |
| 1225 | |
| 1226 | obj.attr[e.a] = e |
| 1227 | assert e in canary.added |
| 1228 | assert e not in canary.appended_wo_mutation |
| 1229 | |
| 1230 | with canary.defer_dupe_check(): |
| 1231 | # __setitem__ sets every time |
| 1232 | obj.attr[e.a] = e |
| 1233 | assert e in canary.added |
| 1234 | assert e not in canary.appended_wo_mutation |
| 1235 | |
| 1236 | if hasattr(obj.attr, "update"): |
| 1237 | e = creator() |
| 1238 | obj.attr.update({e.a: e}) |
| 1239 | assert e in canary.added |
| 1240 | assert e not in canary.appended_wo_mutation |
| 1241 | |
| 1242 | obj.attr.update({e.a: e}) |
| 1243 | assert e in canary.added |
| 1244 | assert e in canary.appended_wo_mutation |
| 1245 | |
| 1246 | e = creator() |
| 1247 | obj.attr.update(**{e.a: e}) |
| 1248 | assert e in canary.added |
| 1249 | assert e not in canary.appended_wo_mutation |
| 1250 | |
| 1251 | obj.attr.update(**{e.a: e}) |
| 1252 | assert e in canary.added |
| 1253 | assert e in canary.appended_wo_mutation |
| 1254 | |
| 1255 | if hasattr(obj.attr, "setdefault"): |
| 1256 | e = creator() |
| 1257 | obj.attr.setdefault(e.a, e) |
| 1258 | assert e in canary.added |
| 1259 | assert e not in canary.appended_wo_mutation |
| 1260 | |
| 1261 | obj.attr.setdefault(e.a, e) |
no test coverage detected