OpenAstronomy/github-actions-workflows

Running tests that are not in the src structure

Closed this issue · 5 comments

I've tried the wheel building workflows and I can't get it to work if the package has the tests separate from the code, e.g.

package
| src/
|    |  ...
| tests /
|    |  ...
| pyproject.toml

I think the reason for this is the wheel building workflows only have the installed dist available, so if you aren't packaging your tests you can't run your tests.

I guess also for the pure-python flavor?

I think the reason for this is the wheel building workflows only have the installed dist available, so if you aren't packaging your tests you can't run your tests.

Thanks for the quick diagnosis!
That is a major drawback. The tests in tests/ all do import <package>, so they should pick up the installed dist, if only the folder could be accessed by pytest. Is there any way to cd into the folder and run the tests/ ?

You should be able to run extra commands before running pytest. If you try test_command: cd $GITHUB_WORKSPACE; pytest tests/ (or maybe even test_command: pytest $GITHUB_WORKSPACE/tests/) in your workflow config, pytest should be able to successfully collect the tests within your repo's tests/ directory.

I ended up finding that {project} links to $HOME/../projects/