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

bpo-44686 replace unittest.mock._importer with pkgutil.resolve_name #18544

Merged
merged 5 commits into from Jul 21, 2021

Conversation

@graingert
Copy link
Contributor

@graingert graingert commented Feb 18, 2020

https://bugs.python.org/issue44686

Automerge-Triggered-By: GH:cjw296

@codecov
Copy link

@codecov codecov bot commented Feb 18, 2020

Codecov Report

Merging #18544 into master will decrease coverage by 0.05%.
The diff coverage is n/a.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
Lib/distutils/tests/test_bdist_rpm.py 30.00% <0.00%> (-65.00%) ⬇️
Lib/distutils/command/bdist_rpm.py 7.63% <0.00%> (-56.88%) ⬇️
Lib/test/test_urllib2net.py 76.92% <0.00%> (-13.85%) ⬇️
Lib/test/test_smtpnet.py 78.57% <0.00%> (-7.15%) ⬇️
Lib/ftplib.py 63.85% <0.00%> (-6.06%) ⬇️
Lib/test/test_ftplib.py 87.11% <0.00%> (-4.72%) ⬇️
Tools/scripts/db2pickle.py 17.82% <0.00%> (-3.97%) ⬇️
Tools/scripts/pickle2db.py 16.98% <0.00%> (-3.78%) ⬇️
Lib/test/test_socket.py 71.94% <0.00%> (-3.77%) ⬇️
Lib/test/test_asyncio/test_base_events.py 91.84% <0.00%> (-3.30%) ⬇️
... and 46 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8edfc47...077c3bc. Read the comment docs.

@tirkarthi
Copy link
Member

@tirkarthi tirkarthi commented Feb 19, 2020

I think this deserves a discussion and a bpo. @cjw296 this uses pkgutil.resolve_name which is a new feature in 3.9 and the backport needs to accommodate the change if merged.

@@ -1583,8 +1565,7 @@ def _get_target(target):
except (TypeError, ValueError):
raise TypeError("Need a valid target to patch. You supplied: %r" %
(target,))
getter = lambda: _importer(target)
return getter, attribute
return partial(pkgutil.resolve_name, target), attribute

This comment has been minimized.

@FFY00

FFY00 May 20, 2020
Member

Is there any reason here to be using functools.partial over lambda?

This comment has been minimized.

@graingert

graingert Jul 20, 2021
Author Contributor

for consistency. lambda: is used twice in this file whereas partial( is used six times

@cjw296
Copy link
Contributor

@cjw296 cjw296 commented May 21, 2020

@tirkarthi: Looking at the diff, we could probably just skip backporting this one...

@graingert graingert requested a review from cjw296 as a code owner Jul 20, 2021
@graingert graingert changed the title replace unittest.mock._importer with pkgutil.resolve_name bpo-44686 replace unittest.mock._importer with pkgutil.resolve_name Jul 20, 2021
@graingert graingert requested a review from FFY00 Jul 20, 2021
@graingert
Copy link
Contributor Author

@graingert graingert commented Jul 20, 2021

I think this deserves a discussion and a bpo. @cjw296 this uses pkgutil.resolve_name which is a new feature in 3.9 and the backport needs to accommodate the change if merged.

I've now created the bpo

@cjw296
cjw296 approved these changes Jul 21, 2021
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 21, 2021

@graingert: Status check is done, and it's a success .

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 21, 2021

@graingert: Status check is done, and it's a success .

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 21, 2021

Sorry, I can't merge this PR. Reason: 3 of 5 required status checks have not succeeded: 1 expected..

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 21, 2021

@graingert: Status check is done, and it's a success .

@miss-islington miss-islington merged commit ab7fcc8 into python:main Jul 21, 2021
12 checks passed
12 checks passed
@github-actions
Docs
Details
@github-actions
Check for source changes
Details
@github-actions
Check if generated files are up to date
Details
@github-actions
Windows (x86)
Details
@github-actions
Windows (x64)
Details
@github-actions
macOS
Details
@github-actions
Ubuntu
Details
@github-actions
Ubuntu SSL tests with OpenSSL
Details
@github-actions
Address sanitizer Address sanitizer
Details
@travis-ci
Travis CI - Pull Request Build Passed
Details
@bedevere-bot
bedevere/issue-number Issue number 44686 found
Details
@bedevere-bot
bedevere/news News entry found in Misc/NEWS.d
@graingert graingert deleted the graingert:patch-3 branch Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants