]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Don't report deleted attributes in __dir__ (GHGH-10148)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 6 Jun 2019 10:39:30 +0000 (03:39 -0700)
committerGitHub <noreply@github.com>
Thu, 6 Jun 2019 10:39:30 +0000 (03:39 -0700)
commit28be388e69c6e88d5c04abcc714db5ec526e4f5e
tree8effe3d039ccb38af0ba67be056a16ea65996825
parentf62a372928fbf6a2ba722f12f069b75ca6ad16fb
Don't report deleted attributes in __dir__ (GHGH-10148)

When an attribute is deleted from a Mock, a sentinel is added rather
than just deleting the attribute. This commit checks for such sentinels
when returning the child mocks in the __dir__ method as users won't
expect deleted attributes to appear when performing dir(mock).
(cherry picked from commit 0df635c7f8aa69e56a092bd4f142f0f164741ab2)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
Lib/unittest/mock.py
Lib/unittest/test/testmock/testmock.py
Misc/NEWS.d/next/Library/2018-10-27-11-54-12.bpo-35082.HDj1nr.rst [new file with mode: 0644]