forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
area-testingverification-neededVerification of issue is requestedVerification of issue is requestedverifiedVerification succeededVerification succeeded
Milestone
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.pywhich addsunittestadapterto path at index 0. - In some tests that import a file from utils, it will first search within the
unittestadapterdirectory 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
unittestadapterdirectory.
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_dirto be one directory deep, we can conclude that if thestart_diris not "." or contains a "/", that we need to add thatstart_dir'sparent to PATH. Otherwise, we simply add thestart_dirto PATH.
Metadata
Metadata
Assignees
Labels
area-testingverification-neededVerification of issue is requestedVerification of issue is requestedverifiedVerification succeededVerification succeeded