nbcelltests
nbcelltests copied to clipboard
Generate test notebooks on the fly rather than using actual, stored notebooks
Currently, nbcelltests' tests use various .ipynb files stored in nbcelltests/tests. Instead, we should generate notebooks as needed during the tests.
Doing this will allow various bits of test code to be simplified.
Hi I am interested doing this issue, but can we use other library to generate test notebooks or it is better to code it from scratch to generate jupyter notebook?
Yes @michiboo thanks for checking - definitely better to use a library if that's possible.
I was imagining using something like nbformat
's new_notebook()
. E.g. here it is being used in nbval: https://github.com/computationalmodelling/nbval/blob/3597e0bfd96c8b52d9f4e94abbe1cbb3887dcf25/tests/utils.py#L5
I think I would probably start off by replacing the notebooks associated with https://github.com/jpmorganchase/nbcelltests/blob/master/nbcelltests/tests/test_lint.py and see how that works out.
Four notes I can think of right now:
- I'd like to leave a least one actual notebook file around, associated with a test that nbcelltests does actually work with a real file :)
- Just to warn you: a part of this task might be improving the tests themselves. There is probably some overlap between unit tests, partially because some re-use the same underlying notebook files. Ideally improving the tests would be a separate task (i.e. should be possible to do a straight up "generate the notebooks" replacement for "physical notebooks" only, but also possible that something blocks that).
- Testing tools that are themselves test tools can be tricky, so please feel free to ask if you see something that looks weird - it might be just bad code, or it might be necessary for some awkward reason.
- This task will leave you with a negative "line count contribution" to the project. That's the second best kind of contribution - second only to preventing lines being written in the first place :)
Hi, I'd like to contribute on this issue, I am currently looking at the codebase and understand the working