fix: ignore workspace root when running pytest#858
fix: ignore workspace root when running pytest#858hyyking wants to merge 5 commits intoastral-sh:mainfrom
Conversation
| all: bool, | ||
| /// Perform the operation on a specific package | ||
| #[arg(short, long)] | ||
| #[arg(short, long, conflicts_with = "all")] |
There was a problem hiding this comment.
Not necessary but I think it makes sense to conflict both
| .with_extension(EXE_EXTENSION); | ||
|
|
||
| let projects = locate_projects(project, cmd.all, &cmd.package[..])?; | ||
| let projects = locate_projects(project, cmd.all | cmd.package.is_empty(), &cmd.package[..])?; |
There was a problem hiding this comment.
Covers 3 branches in the workspace case:
rye test --all: all pyprojects are returnedrye test: before would only return the root -> now returns the same as--allrye test -p <workspace_project>: returns the matched projects
There was a problem hiding this comment.
I don't think that rye test should run all. It was intended to only run the tests of the package you are in. That is consistent with fmt and lint.
There was a problem hiding this comment.
I went by the cargo test implementation.
Although I see your point running pytests at the root directory would collect ANY test file such as exposed in #853 and #893
I see three options:
- Assume the default test directory is
testsand allow the user to override with arye.test-directoryproperty - Run all the packages in the workspace like
cargo test(as implemented) - Leave it to the user to configure
tool.pytestlike in Ignoretargetwhen runningpytestin rye #893
| } | ||
|
|
||
| for (idx, project) in projects.iter().enumerate() { | ||
| if project.workspace().is_some() && project.is_workspace_root() { |
There was a problem hiding this comment.
is_workspace_root would return true if it was single package so we need to ask for the workspace
| .with_extension(EXE_EXTENSION); | ||
|
|
||
| let projects = locate_projects(project, cmd.all, &cmd.package[..])?; | ||
| let projects = locate_projects(project, cmd.all | cmd.package.is_empty(), &cmd.package[..])?; |
There was a problem hiding this comment.
I don't think that rye test should run all. It was intended to only run the tests of the package you are in. That is consistent with fmt and lint.
Fixes #853
Description
When running within a workspace pytest will be run from the project root collecting everything in the workspace tree, including the unselected packages(if root is selected) and packages/folders not managed in the workspace (if all selected).
Open Questions
It might the interesting to have a
rye.test-folderpyproject attribute so we could have workspace tests.