QuantEcon / sphinxcontrib-jupyter

A Sphinx Extension for Generating Jupyter Notebooks
BSD 3-Clause "New" or "Revised" License
77 stars 23 forks source link

TEST: Setup Testing Infrastructure for RST to IPYNB #34

Closed mmcky closed 6 years ago

mmcky commented 6 years ago

This PR sets up the infrastructure for testing rst to ipynb conversions. I have put this test infrastructure at the root level of the repository in tests/ under the idea that they live outside of the standard python testing framework such as pytest which should live sphinxcontrib/jupyter/tests/.

Next Steps:

mmcky commented 6 years ago

@vidartf you might have a quick answer for this question about nbdime. From my testing today the exit code for nbdiff is 0 regardless of whether there are (or are not) differences in the notebooks. I am just wondering what the best way would be to test for the condition that there are no differences between two notebooks.

mmcky commented 6 years ago
mmcky commented 6 years ago

I have used nbformat and nbdime.diffing.notebooks to check for notebook differences in check_diffs.py. The Makefile can run this script to check newly compiled ipynb output against a collection of REFERENCE notebooks located in tests/ipynb

mmcky commented 6 years ago

Migrating test case files from https://github.com/nthiery/rst-to-ipynb/tree/master/tests. (Thanks @nthiery)

Not Migrating

TODO

vidartf commented 6 years ago

From my testing today the exit code for nbdiff is 0 regardless of whether there are (or are not) differences in the notebooks.

The simplest way is to check for output in stdout. If it is empty, the requested diff is empty.

mmcky commented 6 years ago

Great - thanks @vidartf.

vidartf commented 6 years ago

That being said, I think your decision to use nbdime as a library is better. You get more control about the nuances. See e.g. nbdime.diffing.notebooks.set_notebook_diff_targets(), either for use or as inspiration.

mmcky commented 6 years ago

Ah - I see - Thanks for highlighting this. It might be good to be able to switch off checks on metadata etc. https://github.com/jupyter/nbdime/blob/e9ba0e490e40892b207de75fa0726dfc4848b52e/nbdime/diffing/notebooks.py#L530

mmcky commented 6 years ago

Moved rst2ipynb test cases to its own folder and will work on migrating them in one by one and reviewing each for differences.