classification
Title: Mock.__dir__ lists deleted attributes
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7
process
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 2019-06-06 10:40 by asvetlov. 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.
History
Date User Action Args
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