-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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.patch with autospec doesn't hold for classmethods nor staticmethods #102978
Comments
Looks like the signature is not set for |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Apr 13, 2023
…ticmethod decorators (pythonGH-103228) Fixes unittest.mock.patch not enforcing function signatures for methods decorated with @classmethod or @staticmethod when patch is called with autospec=True. (cherry picked from commit 59e0de4) Co-authored-by: Tomas R <[email protected]>
cjw296
pushed a commit
that referenced
this issue
Apr 13, 2023
…hod decorators (#103228) Fixes unittest.mock.patch not enforcing function signatures for methods decorated with @classmethod or @staticmethod when patch is called with autospec=True.
carljm
added a commit
to carljm/cpython
that referenced
this issue
Apr 13, 2023
* main: pythongh-103479: [Enum] require __new__ to be considered a data type (pythonGH-103495) pythongh-103365: [Enum] STRICT boundary corrections (pythonGH-103494) pythonGH-103488: Use return-offset, not yield-offset. (pythonGH-103502) pythongh-103088: Fix test_venv error message to avoid bytes/str warning (pythonGH-103500) pythonGH-103082: Turn on branch events for FOR_ITER instructions. (python#103507) pythongh-102978: Fix mock.patch function signatures for class and staticmethod decorators (python#103228) pythongh-103462: Ensure SelectorSocketTransport.writelines registers a writer when data is still pending (python#103463) pythongh-95299: Rework test_cppext.py to not invoke setup.py directly (python#103316)
aisk
pushed a commit
to aisk/cpython
that referenced
this issue
Apr 18, 2023
…ticmethod decorators (python#103228) Fixes unittest.mock.patch not enforcing function signatures for methods decorated with @classmethod or @staticmethod when patch is called with autospec=True.
ambv
pushed a commit
that referenced
this issue
May 22, 2023
…aticmethod decorators (GH-103228) (#103499) Fixes unittest.mock.patch not enforcing function signatures for methods decorated with @classmethod or @staticmethod when patch is called with autospec=True. (cherry picked from commit 59e0de4) Co-authored-by: Tomas R <[email protected]>
jscarfo11
added a commit
to Purdue-EBEC/generic-grader
that referenced
this issue
Jan 13, 2025
jscarfo11
added a commit
to Purdue-EBEC/generic-grader
that referenced
this issue
Jan 13, 2025
jhcole
pushed a commit
to Purdue-EBEC/generic-grader
that referenced
this issue
Jan 22, 2025
jhcole
pushed a commit
to Purdue-EBEC/generic-grader
that referenced
this issue
Jan 22, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
Using
patch
withautospec=True
does not work when a method is decorated with@classmethod
or@staticmethod
. The resulting mock can be called with any arguments without raising aTypeError
.Example:
The only subtest that fails is
foo
. The other two pass, even though they're clearly being called incorrectly.If you prefer not to use
pytest
to demo/repro this:This has output:
Your environment
Linked PRs
The text was updated successfully, but these errors were encountered: