treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
179 stars 18 forks source link

Add an option to specify the pattern of notebook files to include in tests (eg "test-*.ipynb") #82

Closed furechan closed 1 year ago

furechan commented 1 year ago

It is possible to run pytest --nbmake in a project folder to collect tests both as .py files and .ipynb files. This however will collect all notebooks in the tree. In my projects there are notebooks for different purposes and some are for testing only. It would be nice to have an option to specify the pattern of notebooks to include in the tests (say "test-*.ipynb"). This option ideally could be set in the pyproject.toml file. So that one can run pytest --nbmake in any project and be sure to pick all relevant tests be it python or notebook.

alex-treebeard commented 1 year ago

Hi @furechan, this should be possible using pytest arguments.

Can you try

pytest --nbmake my_dir

I recommend checking out pytest docs as there are lots of options for selecting which tests to run.

furechan commented 1 year ago

hi @alex-treeboard,

Yes it is possible to specify folders like you suggest.

Say you have your test files in ./tests and your test notebooks in ./nbtests the following works and collects pure tests as well as notebooks tests.

pytest --nbmake tests nbtests

This works if all test notebooks have been segregated in a dedicated folder which I guess is a reasonable requirement.

Thanks