-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Test suite discovery error on imports that use shared filenames with the pythonFiles>unittestadapter directory #22453
Comments
thanks again for contributing to the repo and putting in this fix! |
…osoft#22454) [Issue microsoft#22453](microsoft#22453) - Once starting to run discovery, add the projects root path to PATH at index 0 so that any further imports will use the projects root directory and not reference the incorrect directory. - Since the test suite only allows the start_dir to be one directory deep, we can conclude that if the start_dir is not "." or contains a "/", that we need to add that start_dir's parent to PATH. Otherwise, we simply add the start_dir to PATH.
should be able to verify with the following set up: project structure with
test which should now work:
made a zip of a project that should replicate this: |
@eleanorjboyd I'm still seeing the import error mentioned in the description: I might be missing a few setup steps but would like to learn. |
What do you have as your settings for your unittest args? |
Due to PATH ordering, shared directory/file names in a users codebase with the
pythonFiles > unittestadapter
directory will fail.Error:
ModuleNotFoundError: No module named 'utils.<name>; 'utils' is not a package
Problem:
discovery.py
which addsunittestadapter
to path at index 0.unittestadapter
directory due to PATH orderingunittestadapter
directory.Solution:
start_dir
to be one directory deep, we can conclude that if thestart_dir
is not "." or contains a "/", that we need to add thatstart_dir's
parent to PATH. Otherwise, we simply add thestart_dir
to PATH.The text was updated successfully, but these errors were encountered: