Bugfix: monkeypatch.delattr handles class descriptors#4537
Conversation
Correct monkeypatch.delattr to match the correct behavior of monkeypatch.setattr when changing class descriptors
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks for the contribution @chdsbd!
Codecov Report
@@ Coverage Diff @@
## master #4537 +/- ##
==========================================
- Coverage 95.92% 95.87% -0.06%
==========================================
Files 111 111
Lines 25119 25141 +22
Branches 2449 2450 +1
==========================================
+ Hits 24096 24104 +8
- Misses 723 731 +8
- Partials 300 306 +6
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #4537 +/- ##
==========================================
- Coverage 95.92% 95.91% -0.02%
==========================================
Files 111 111
Lines 25119 25141 +22
Branches 2449 2450 +1
==========================================
+ Hits 24096 24114 +18
- Misses 723 726 +3
- Partials 300 301 +1
Continue to review full report at Codecov.
|
| raise AttributeError(name) | ||
| else: | ||
| self._setattr.append((target, name, getattr(target, name, notset))) | ||
| oldval = getattr(target, name, notset) |
There was a problem hiding this comment.
this inadvertently triggers misbehaviours
a) ignores the MRO
b) always goes the normal path, even for classes
There was a problem hiding this comment.
I'm confused how this is different from the current behavior of setattr. I believe this works the exact same as before, except in the case of the class, where we match the behavior of setattr.
Is there an example you can provide to correct my misunderstanding?
There was a problem hiding this comment.
I think I understand what you be regarding b. I mimicked the implementation for monkeypatch.setattr. I can update both of them if you want to use an if-else.
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
its good now, thanks for the ping
|
Thanks again @chdsbd! |

Correct monkeypatch.delattr to match the correct behavior of monkeypatch.setattr when changing class descriptors.
Issue: #4536