-
Notifications
You must be signed in to change notification settings - Fork 33
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
stestr ignores PYTHONPATH? #278
Comments
I tried to recreate this locally but I'm unable to get it to fail. Granted I may not have perfectly mirrored the structure you have in your project but I created locally this structure:
While I didn't have any contents in the modules since I don't know what you're doing for these I did put import statements as you outlined:
I did write a single test case in test_unit.py and imported app just to verify it doesn't error from that:
Then running stestr with PYTHONPATH set to the absolute path to
This is actually consistent with my expectations, stestr launches each test worker (and does test discovery) in a subprocess that doesn't explicitly set env, which means all the env variables from the parent process get passed through to the workers. So when we launch new processes to do the actual execution here: https://github.com/mtreinish/stestr/blob/master/stestr/test_processor.py#L188 (which gets called here https://github.com/mtreinish/stestr/blob/master/stestr/test_processor.py#L202 and https://github.com/mtreinish/stestr/blob/master/stestr/test_processor.py#L241) the PYTHONPATH env variable should be set when it launches the new python binary to actually run the tests. I'm not going to close this yet since I might have missed something in my reproduction attempt, but I'm not able to debug any potential issue here without being able to reproduce the failure. Is the specific project that's failing for you open source or hosted somewhere I can access and try this locally? |
Hi @mtreinish , Thank you very much for testing this. My configuration can actually work if I change
i.e instead of |
Interesting, it did work with me with the stestr.conf as:
located in I was going to suggest you change the top dir when I first read the issue because top_dir is basically the cwd for discovery. It's what unittest treats as the root of the project. But I didn't suggest that because it looked like your |
Issue description
Test ('test_unit.py') does not run because of the ImportError of another module. Direct execution of the test_unit.py works, as well as running via pytest.
Expected behavior and actual behavior
Expected that the test runs fine.
Actual behavior: fails to run
Steps to reproduce the problem
I have the following structure:
PYTHONPATH=/top_dir/common_tools
.stestr.conf is located in
/top_dir/my_package
:app.py has
import tools as tl
tools.py has
from tool_one import tool_one_config
running "python app.py" works fine.
running "pytest src/tests/test_unit.py" is also fine.
However, running from
/top_dir/my_package
"stestr -v run" fails withSpecifications like the version of the project, operating system, or hardware
System information
Ubuntu 16.04
python 3.5.2
stestr 2.5.1
Additional information
The text was updated successfully, but these errors were encountered: