You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the following famous Python project structure [1,2,3,4], the "src" directory is not appended to the "tests" Python path automatically. Actually, the reason for selecting this structure is forcing the developers to test the installed library (editable in development time, non-editable before pushing to the repository) which prevents some packaging (such as invalid patterns in MANIFEST.in) problems.
which doesn't include the src directory. However, the src is determined as a source root by running ./pants roots:
.
src
On the other hand, if you use ./pants tailor which puts different BUILD files for the tests and src/foolib (not the src directory itself) directories, it works well (the src directory is included in sys.path, and the tests run without import problem) while the source roots are the same.
Pants version: 2.10.0 OS: Linux Ubuntu 18.04.4 LTS
The text was updated successfully, but these errors were encountered:
AlirezaRoshanzamir
changed the title
The source root doesn't apply to tests that exist in a different directory when there is a single BUILD file for each project.
The "src" source root doesn't apply to tests that exist in a different directory when there is a single BUILD file for each project.
Apr 10, 2022
Ah, hm, interesting. I think the BUILD file needs to be inside the source root. So you might need to have two BUILD files instead of one (one in src/ and one in test/) but you still don't need one in every subdir (which is what tailor generates) if you don't want that.
Bug Description:
Using the following famous Python project structure [1,2,3,4], the "src" directory is not appended to the "tests" Python path automatically. Actually, the reason for selecting this structure is forcing the developers to test the installed library (editable in development time, non-editable before pushing to the repository) which prevents some packaging (such as invalid patterns in MANIFEST.in) problems.
Running
./pants test :tests
results:and the
sys.path
value for the running tests is:which doesn't include the
src
directory. However, thesrc
is determined as a source root by running./pants roots
:On the other hand, if you use
./pants tailor
which puts different BUILD files for thetests
andsrc/foolib
(not thesrc
directory itself) directories, it works well (thesrc
directory is included insys.path
, and the tests run without import problem) while the source roots are the same.Pants version: 2.10.0
OS: Linux Ubuntu 18.04.4 LTS
The text was updated successfully, but these errors were encountered: