Allow setting dictionary items in MagicDict by setting attributes
Requires !124 (merged), closes #81 (closed)
A slightly annoying issue when writing tests for workers that should handle both Element and CachedElement: setting an attribute on a MagicDict does not set its item.
>>> e = Element()
>>> e.id = '…'
>>> e["id"]
KeyError: 'id'
Since CachedElement does not have key-based access (e["id"]
), if they set attributes on an Element, they might not be visible as dictionary keys. This changes the MagicDict behavior to just always set dictionary keys; the MagicDict's __getattr__
can retrieve those keys anyway, so it works transparently.
Edited by Erwan Rouchet
Merge request reports
Activity
added 1 commit
- 9b1c9a6e - Allow setting dictionary items in MagicDict by setting attributes
requested review from @babadie
added 3 commits
-
facffb12...4222593a - 2 commits from branch
master
- fc9874df - Allow setting dictionary items in MagicDict by setting attributes
-
facffb12...4222593a - 2 commits from branch
enabled an automatic merge when the pipeline for fc9874df succeeds
Please register or sign in to reply