Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest.mock's patch.object and patch.dict are not supported on classmethod, propery and staticmethod #80273

Closed
tirkarthi opened this issue Feb 23, 2019 · 5 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@tirkarthi
Copy link
Member

BPO 36092
Nosy @cjw296, @voidspace, @mariocj89, @remilapeyre, @tirkarthi, @jacksonriley

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2019-11-12.11:07:20.521>
created_at = <Date 2019-02-23.06:51:44.800>
labels = ['3.7', '3.8', 'type-bug', 'library']
title = "unittest.mock's patch.object and patch.dict are not supported on classmethod, propery and staticmethod"
updated_at = <Date 2019-11-12.11:28:07.029>
user = 'https://github.com/tirkarthi'

bugs.python.org fields:

activity = <Date 2019-11-12.11:28:07.029>
actor = 'jacksonriley'
assignee = 'none'
closed = True
closed_date = <Date 2019-11-12.11:07:20.521>
closer = 'xtreak'
components = ['Library (Lib)']
creation = <Date 2019-02-23.06:51:44.800>
creator = 'xtreak'
dependencies = []
files = []
hgrepos = []
issue_num = 36092
keywords = []
message_count = 4.0
messages = ['336372', '356426', '356439', '356445']
nosy_count = 6.0
nosy_names = ['cjw296', 'michael.foord', 'mariocj89', 'remi.lapeyre', 'xtreak', 'jacksonriley']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue36092'
versions = ['Python 3.7', 'Python 3.8']

@tirkarthi
Copy link
Member Author

While looking into the unittest.mock tests I came across test_patch_descriptor [0] which makes an early return since patch.object and patch.dict are not supported on staticmethod, classmethod and property as noted in the comment. The tests still fail on master. The test was added during initial addition of mock to stdlib (commit 345266a) and I couldn't find any issues related to this. So I am filing this if someones wants to fix it.

[0]

def test_patch_descriptor(self):

@tirkarthi tirkarthi added 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Feb 23, 2019
@jacksonriley
Copy link
Mannequin

jacksonriley mannequin commented Nov 12, 2019

Hi Karthikeyan,

It seems that test_patch_descriptor has been removed by Chris Withers on 1st of May 2019 under commit adbf178.

I would therefore propose that this bug be marked as closed/resolved.

Cheers,
Jackson

@tirkarthi
Copy link
Member Author

Thanks Jackson for the information. I am fine with closing it as outdated and one can reopen if they need this along with reviving the removed tests in the PR.

@jacksonriley
Copy link
Mannequin

jacksonriley mannequin commented Nov 12, 2019

Thanks Karthikeyan!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@alonbl
Copy link

alonbl commented Jul 3, 2022

Hi,
I just bumped into this bug as I tried to patch dictionary for setUpClass which is @classmethod.
From the discussion above I did not understand why it was closed as it is a gap in functionality, no?
Thanks,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants