Sample code for Chapter 3 of Fluent Python 2e by Luciano Ramalho (O'Reilly, 2020)
Use Python's standard doctest module, for example:
$ python3 -m doctest bisect_demo.py -v
Install pytest and the nbval plugin:
$ pip install pytest nbval
Run:
$ pytest --nbval