Closed
Description
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:
- When running the test suite, we run
discovery.py
which addsunittestadapter
to path at index 0. - In some tests that import a file from utils, it will first search within the
unittestadapter
directory due to PATH ordering - The discovery will now fail because it detects utils as a file and not a module since its reading the utils.py file from the
unittestadapter
directory.
Solution:
- 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 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.
Metadata
Metadata
Assignees
Labels
Verification of issue is requestedVerification of issue is requestedVerification succeededVerification succeeded