bpo-44686 replace unittest.mock._importer with pkgutil.resolve_name#18544
bpo-44686 replace unittest.mock._importer with pkgutil.resolve_name#18544miss-islington merged 5 commits intopython:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #18544 +/- ##
==========================================
- Coverage 83.25% 83.20% -0.06%
==========================================
Files 1571 1571
Lines 414749 414735 -14
Branches 44456 44453 -3
==========================================
- Hits 345300 345068 -232
- Misses 59795 60019 +224
+ Partials 9654 9648 -6
Continue to review full report at Codecov.
|
|
I think this deserves a discussion and a bpo. @cjw296 this uses |
| (target,)) | ||
| getter = lambda: _importer(target) | ||
| return getter, attribute | ||
| return partial(pkgutil.resolve_name, target), attribute |
There was a problem hiding this comment.
Is there any reason here to be using functools.partial over lambda?
There was a problem hiding this comment.
for consistency. lambda: is used twice in this file whereas partial( is used six times
|
@tirkarthi: Looking at the diff, we could probably just skip backporting this one... |
I've now created the bpo |
Misc/NEWS.d/next/Library/2021-07-20-19-35-49.bpo-44686.ucCGhu.rst
Outdated
Show resolved
Hide resolved
|
@graingert: Status check is done, and it's a success ❌ . |
|
@graingert: Status check is done, and it's a success ✅ . |
|
Sorry, I can't merge this PR. Reason: |
|
@graingert: Status check is done, and it's a success ✅ . |
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place.
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place. Part-of: #112317
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place. X-original-commit: 482cb08
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place.
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place. X-original-commit: 482cb08 Part-of: #112440
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place. Part-of: #112450
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place. Part-of: odoo#112317
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place.
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place.
Since python/cpython#18544, unittest mock is not able to properly find the "odoo.tools.config". When trying to patch the `options` dictionnary, it leads to `AttributeError: module 'odoo.tools.config' has no attribute 'options'` In order to have the tests working in python <= 3.11, we have to import the config module and patch the options in place. Part-of: #151989
Damn, python/cpython#18544 actually changed the behavior.
|
Hi all, sorry to resurrect a very old PR. However, this change actually changed the behavior of the lookup used in the mockers. A clear example is given here: scikit-hep/pyhf#2143 (comment). I wonder if the Python docs for unittest could be changed to include information about the changed behavior. However, I am not sure how to describe the actual changes. |
https://bugs.python.org/issue44686
Automerge-Triggered-By: GH:cjw296