-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Test directory structure and import problems #4115
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
Comments
there's a bunch of dupes about relative imports on so: (and a few others, didn't have time to track them all down) hope this helps! |
This helps to understand more the problem, thanks. I can't understand how people deal with this and why nobody complained about this earlier. I'm pretty sure I'm missing something. |
The mistake wasn't the directory layout but that you were using a relative import which isn't a thing in python3 Is there a code sample in our docs which uses a relative import like yours? |
I don't understand quite well... How is this supposed to work then? You said:
How can someone understand that from the doc? |
the mistakes you made have nothing to do with pytest. that's just how you make modules and import statements in python. the docs aren't intended to teach you how to write import statements (they don't show any code at all so they couldn't have misled you here) |
I don't agree:
and
It's obvious that you have to give at least a simple example if you don't want people to think that imports will be handled nicely out of the box without extra painful work. I don't call this support... |
here's both layouts working fine. There's no pain from imports, this is how any library would be arranged. The imports inside the tests are exactly as they would be if one were a consumer of the library. inside package
outside package(adopted from the top by
|
Works with
Why? |
ah the docs assume you're actually installed (notice how I left out |
I don't know what do you mean by ' installed', could you please elaborate? |
|
Thanks for your explanations! |
also I'm not sure how you found that docs page, it's from a two years old feature branch 😆 |
@The-Compiler any opposition to me deleting that branch (since it's causing confusion / isn't maintained)? |
@asottile this was started as part of the doc reorg from the last pytest sprint - we might want to coordinate with @obestwalter and @pfctdayelise wrt the details (i recall some of those changes being a much needed enhancement, it would be sad if personal time constraints would cause them to be left over/ended |
@RonnyPfannschmidt I think you're referring to this other branch which is only ~ a month old |
@asottile that may be possible as well - i believe @nicoddemus should know then (im a bit out of touch with those branches - i just wanted to ensure we don't loose something we don't want to loose |
https://github.com/pytest-dev/pytest/commits/documentation-restructure has been created so @evildmp could work on the restructuring of the docs (tutorial, how-to, reference, explanation), from a Python talk and summarized in this post: https://www.divio.com/blog/documentation https://github.com/pytest-dev/pytest/commits/reorganize-docs is the branch that @obestwalter, @pfctdayelise, and @hackebrot worked on our sprint. Not sure if they want to keep this branch around or not, given that is probably riddled with conflicts by this point. |
Uh oh!
There was an error while loading. Please reload this page.
Hi!
I don't know if problems with the documentation are to be posted here...
In the Test directory structure page:
These are not working out of the box because of the path problem.
You will have something like:
I've wrote a question on stackoverflow here.
The text was updated successfully, but these errors were encountered: