-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[RFC] --import-mode: allow for "importlib" [ci skip] #5352
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
Conversation
Codecov Report
@@ Coverage Diff @@
## features #5352 +/- ##
============================================
- Coverage 93.96% 85.24% -8.72%
============================================
Files 115 115
Lines 26384 26384
Branches 2607 2607
============================================
- Hits 24792 22492 -2300
- Misses 1269 3514 +2245
- Partials 323 378 +55
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up again!
We should merge this after 4.6 is released, I suspect you already plan to do that though. 😁
Things missing I think:
- Require
py>=1.8.0
- Integration test(s)
- Docs
I do not think we should bump the requirement because of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean
Doesn't that change mean that pytest doesn't have to change |
yeah it would have to be a big shift, I'm still not even sure the full fallout of such a change but from some basic playing with it it seems to make the "duplicated test names problem go away" |
I agree, but at the same time I fear a lot of test suites would simply stop working, and worse, without any guidance from the issuing error message... not sure if we should change that to be the default, TBH. Definitely an option, but just making that the default seems risky... 🤔 |
Yes, but it is not required if not used. |
I also do not think it should be made a default (as of now) - like said before, not being able to use relative imports is a big bummer for me. I've only looked at it briefly, but maybe there's an option to support this somehow. |
Not sure, what's the problem with bumping the requirement to py>=1.8? Seems simpler and straightforward, or are there any drawbacks I'm not seeing here?
Agreed. This gives me the idea that we should update the error message about duplicated modules to mention this option as an alternative, as well as to point to the appropriate docs. |
@@ -109,7 +109,7 @@ def pytest_addoption(parser): | |||
group.addoption( | |||
"--import-mode", | |||
default="prepend", | |||
choices=["prepend", "append"], | |||
choices=["prepend", "append", "importlib"], | |||
dest="importmode", | |||
help="prepend/append to sys.path when importing test modules, " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this help string should be updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
But initially this was just meant to allow for using this easily already (i.e. experimental).
I suppose we can include the option, then we can try it using it more and ask people to do the same. If there are no major show-stoppers, we can change the default in pytest 6.0, while issuing a warning about the upcoming change in defaults. |
Using as a default is not an option really (according to when I've tested it). |
Ref: pytest-dev/py#203