Hacker News new | ask | show | jobs
by tobiadefami 471 days ago
Probly doesn't have built-in test assertion functionality yet, but since it runs Python (via Pyodide) directly in the browser, you can write test functions with assertions in your Python code. The execute_python_code tool in our system can run any valid Python code, including test functions.

This is something we're considering for future development, so this is a great shout!

1 comments

To have tests that can be copied or exported into a .py module from a notebook is advantageous for prototyping and reusability.

There are exploratory/discovery and explanatory forms and workflows for notebooks.

A typical notebook workflow: get it working with Ctrl-Enter and manually checking output, wrap it in a function(s) with defined variable scopes and few module/notebook globals, write a test function for the function which checks the output every time, write markdown and/or docstrings, and then what of this can be reused from regular modules.

nbdev has an 'export a notebook input cell to a .py module' feature. And formatted docstrings like sphinx apidoc but in notebooks. IPython has `%psource module.py` for pygments-style syntax highlighting of external .py modules and `%psave output.py` for saving an input cell to a file, but there are not yet IPython magics to read from or write to certain lines within a file like nbdev.

To run the chmp/ipytest %%ipytest cell magic with line or branch coverage, it's necessary to `%pip install ipytest pytest-cov` (or `%conda install ipytest pytest-cov`)

jupyter-xeus supports environment.yml with jupyterlite with packages from emscripten-forge: https://jupyterlite-xeus.readthedocs.io/en/latest/environmen...

emscripten-forge src: https://github.com/emscripten-forge/recipes/tree/main/recipe... .. web: https://repo.mamba.pm/emscripten-forge