Skip to content

Conversation

@vabr-g
Copy link
Contributor

@vabr-g vabr-g commented Dec 10, 2020

patch, patch.object and create_autospec silently ignore misspelled
arguments such as autospect, auto_spec and set_spec. This can lead
to tests failing to check what they are supposed to check.

This change adds a check causing a RuntimeError if the above
functions get any of the above misspellings as arguments. It also
adds a new argument, "unsafe", which can be set to True to disable
this check.

https://bugs.python.org/issue41877

patch, patch.object and create_autospec silently ignore misspelled
arguments such as autospect, auto_spec and set_spec. This can lead
to tests failing to check what they are supposed to check.

This change adds a check causing a RuntimeError if the above
functions get any of the above misspellings as arguments. It also
adds a new argument, "unsafe", which can be set to True to disable
this check.
@gpshead gpshead self-assigned this Dec 10, 2020
Also revert changes forced by `unsafe` being positional,
and add "!r" to format specifiers in added error messages.
@vabr-g
Copy link
Contributor Author

vabr-g commented Dec 11, 2020

Thanks for the first review round!
I added the changes as a new commit. Please let me know if I should be amending the existing one instead.

Also revert changes forced by `unsafe` being positional,
and add "!r" to format specifiers in added error messages.
@vabr-g
Copy link
Contributor Author

vabr-g commented Dec 11, 2020

I was looking at the failing test_asyncio on Win x64, but it does not seem related. There are no uses of autospec in Lib/test/test_asyncio/test_sendfile.py as far as I can tell, and the issue is weirdly platform-specific.
I'm not sure how to re-run the test, but that will likely solve itself once I push more commits to address comments from further review rounds.

Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all my remaining comments are minor

@gpshead gpshead added type-feature A feature request or enhancement tests Tests in the Lib/test dir labels Dec 14, 2020
@gpshead gpshead merged commit fdb9efc into python:master Dec 14, 2020
@vabr-g vabr-g deleted the issue-41877-arguments-check branch December 14, 2020 19:20
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
patch, patch.object and create_autospec silently ignore misspelled
arguments such as autospect, auto_spec and set_spec. This can lead
to tests failing to check what they are supposed to check.

This change adds a check causing a RuntimeError if the above
functions get any of the above misspellings as arguments. It also
adds a new argument, "unsafe", which can be set to True to disable
this check.

Also add "!r" to format specifiers in added error messages.
openstack-mirroring pushed a commit to openstack/openstacksdk that referenced this pull request Dec 1, 2021
Some clean up have been done in py3.10 [1] and
implemented in [2]. So, we caught this typo
while building package on Fedora with python3.10.
With 'autospec' instead of 'auto_spec' unit tests
fail. As 'autospec' was silently ignored, and in
order to keep same behavior, we remove the
parameter.

[1] https://bugs.python.org/issue41877
[2] python/cpython#23737

Change-Id: I092d48b9806c4cd6f8b2ecbedd7ab5b7c6d20c04
openstack-mirroring pushed a commit to openstack/openstack that referenced this pull request Dec 1, 2021
* Update openstacksdk from branch 'master'
  to 5ff2a9291665b2ad02d0d0b553a7f92381f6fb3f
  - Merge "Remove misspelled speccing arguments"
  - Remove misspelled speccing arguments
    
    Some clean up have been done in py3.10 [1] and
    implemented in [2]. So, we caught this typo
    while building package on Fedora with python3.10.
    With 'autospec' instead of 'auto_spec' unit tests
    fail. As 'autospec' was silently ignored, and in
    order to keep same behavior, we remove the
    parameter.
    
    [1] https://bugs.python.org/issue41877
    [2] python/cpython#23737
    
    Change-Id: I092d48b9806c4cd6f8b2ecbedd7ab5b7c6d20c04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants