rossant / ipycache

Defines a %%cache cell magic in the IPython notebook to cache results of long-lasting computations in a persistent pickle file
BSD 3-Clause "New" or "Revised" License
138 stars 35 forks source link

Rewrite unit tests to use Python `unittest` #66

Closed mbrukman closed 2 years ago

mbrukman commented 2 years ago

This lets us drop the dependency on the deprecated nose library and use the Python standard library unittest. Since we don't use any advanced functionality, and the unittest library is sufficient for our use cases, this means we can remove the dependency on nose without introducing a new dependency on either nose2 or pytest.

Closes https://github.com/rossant/ipycache/issues/61

mbrukman commented 2 years ago

All tests are passing! However, we're still running the tests using nosetests — I wanted to change as little as possible, to make sure everything is still working.

Now, we can remove our dependency on nose and run tests via python -m unittest unstead of nosetests and get the same functionality. Hopefully, it'll be even slightly faster overall due to having to install fewer packages!

mbrukman commented 2 years ago

Looks like all tests are "passing", but Python 2 isn't actually running tests. Maybe it needs python -m unittest discover rather than simply python -m unittest which seems to work in Python 3?

mbrukman commented 2 years ago

Our tests are now faster (this is Python 3.7 on Ubuntu 20.04, sample size of 1, so usual caveats):

And now, python -m unittest discover works in Python 2 and Python 3, and dropping the nose dependency lets us enable running on Python 3.10 as well with no changes!

Success! 🎉