Switch from deprecated imp to importlib#5468
Switch from deprecated imp to importlib#5468asottile merged 1 commit intopytest-dev:masterfrom asottile:switch_importlib_to_imp
Conversation
|
Awesome, thanks! This is really great, that I will try to take a look ASAP, possibly tomorrow. |
|
oops this isn't ready yet, I broke package imports somehow? need to look more into that 👍 |
|
Ahh OK. 👍 |
Codecov Report
@@ Coverage Diff @@
## master #5468 +/- ##
==========================================
+ Coverage 96.03% 96.07% +0.03%
==========================================
Files 115 115
Lines 25512 25458 -54
Branches 2480 2468 -12
==========================================
- Hits 24501 24458 -43
+ Misses 706 697 -9
+ Partials 305 303 -2
Continue to review full report at Codecov.
|
|
ok I think this works now |
src/_pytest/assertion/rewrite.py
Outdated
| return tp == imp.PKG_DIRECTORY | ||
| _, _, modname = name.rpartition(".") | ||
| spec = self._find_dotted_spec(name) | ||
| return spec and spec.loader.is_package(modname) |
There was a problem hiding this comment.
this is by far my least favorite part of this patch :S -- I couldn't find a better way to do this though
|
fairly certain the flakey failures are related to this patch 🤔 -- but I'm not sure where I need to put the |
|
with pytest testing/python/integration.py -k test_mockstill not sure what's up with it though :/ |
|
oh but that reproduction isn't even valid, this is a tough one :S |
|
OK, I figured this out and added another test for another github issue (validated it failed on macos before my change) |
nicoddemus
left a comment
There was a problem hiding this comment.
Awesome work @asottile! Please take a look at my comments and let me know what you think.
| PYTEST_TAG = "{}-{}{}-PYTEST".format(impl, ver[0], ver[1]) | ||
| del ver, impl | ||
|
|
||
| PYTEST_TAG = "{}-PYTEST".format(sys.implementation.cache_tag) |
There was a problem hiding this comment.
From https://docs.python.org/3/library/sys.html#sys.implementation:
If cache_tag is set to None, it indicates that module caching should be disabled.
So we need to account for that. Because of this we should also add some tests where we execute a few tests in a subprocess with bytecode caching disabled to ensure we don't regress.
There was a problem hiding this comment.
seems not a regression here -- would be happy to schedule this as a followup though (I believe there's already a check below for sys.dont_write_bytecode or whatever the flag is, so I suspect this being None doesn't matter (the string formatting still succeeds))
There was a problem hiding this comment.
Hmmm I recall we had a py27-xdist-nobyte run or something were bytecode was disabled. I don't think we have that anymore, so we might introduce regressions by mistake.
I don't believe we need an entire tox environment for that, but we might consider one test which executes a few tests in a subprocess to ensure we don't regress.
There was a problem hiding this comment.
You are absolutely right 😉
pytest/testing/test_assertrewrite.py
Lines 745 to 755 in 3f5b078
|
Does this fix #2419 too? |
I'm not sure, it wasn't clear to me how to reproduce that one |
No problem, we should make a note or something to post a question to the OP if they can reproduce the issue with 5.0 (once released). 👍 |
|
let me comb through the |
|
note: this will not be backported as we can't support the same functionality in python2 / python3.4 due to missing importlib apis |
|
Hi, unless I'm mistaken this change has been merged and released in version 5.0.0, however I'm still having the deprecation warning message using this version... Am I missing something? 🤔 |
|
Hi @falzm,
I suggest passing |
|
Thank you @nicoddemus. |
|
Hoping this is the right place to post this...if not please help guide me to the right place? I just stood up a brand new pyramid project using cookiecutter starter for 1.10 and this is still a thing: https://docs.pytest.org/en/latest/changelog.html#id68 My env (baz is the pyramid project folder):
I am executing pytest using a local setup.sh file, which includes running the tests: The 2 default pyramid tests pass but I get a warnings summary with 3 warnings: According to all of the docs I found, this should not be possible because this was fixed in pytest 5.0.0 however, I can see there is a reference to a PR from Aug (~2months ago) that indicate that maybe there is still some Workarounds I tried (but did not fix the problem):
...but the results are always the same. For the first warning, caused by It strikes me as funny that this warning is still a thing, but, I stopped laughing a little while ago now. Perhaps I'm being a perfectionist in spending time on making this warning go away but it would be really tight to have this sorted before I dive into full TDD so I can see clean output for what is essentially 2 hello word test cases. Thank you to everyone who read this far - you're the best. (edits made to clarify original post, and, formatting for readability) |
|
you'll want to report that to the venusian project |
|
Just to complement @asottile's answer, pytest is warning about Notice that the warning location points to |
Resolves #1403
Resolves #2761
Resolves #5078
Resolves #5432
Resolves #5433