This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Mock.__dir__ lists deleted attributes
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: mariocj89, michael.foord
Priority: low Keywords: patch

Created on 2018-10-27 10:45 by mariocj89, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 10148 merged mariocj89, 2018-10-27 10:50
PR 13859 merged miss-islington, 2019-06-06 10:39
Messages (1)
msg328647 - (view) Author: Mario Corchero (mariocj89) * (Python triager) Date: 2018-10-27 10:45
Calling dir on unittest.mock.Mock will return deleted attributes.

This is a result of the way del is implemented in Mock, which just sets a sentinel in the child mocks, so an AttributeError is raised if the attribute is later accessed.

We can just check for such sentinel in the __dir__ method and not return those.
Date User Action Args
2022-04-11 14:59:07adminsetgithub: 79263
2019-06-06 10:40:30asvetlovsetversions: + Python 3.7
2019-06-06 10:40:24asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-06-06 10:39:08miss-islingtonsetpull_requests: + pull_request13735
2018-10-27 14:44:34serhiy.storchakasetnosy: + michael.foord
2018-10-27 10:50:57mariocj89setkeywords: + patch
stage: patch review
pull_requests: + pull_request9476
2018-10-27 10:45:10mariocj89create