pytest tests with ipytest
The ipytest module is available in Basthon. It lets you write pytest tests directly in the console or in a cell of the notebook:
python
import ipytest
ipytest.autoconfig()
def mean(marks):
return sum(marks) / len(marks)
def test_mean():
assert mean([10, 12, 14]) == 12
def test_empty_list():
assert mean([]) == 0
ipytest.run()asserts are detailed as with pytest: you see straight away which test fails and why. The %%ipytest magic command does not exist in Basthon: call ipytest.run().