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

Migrate from `nose` to `nose2` #62

Closed mbrukman closed 2 years ago

mbrukman commented 2 years ago

As described in this issue and our CI config, nose is deprecated and unmaintained, and incompatible with Python 3.10 and 3.11, and we need to upgrade to nose2 or another solution. We're choosing nose2 since it's closest to nose, so unless there are critical issues with nose2 and this codebase, we should be fine with that approach for now.

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

mbrukman commented 2 years ago

Looks like this is not so simple, as tests are failing with this error:

Run nose2 -v --pretty-assert
test_ipycache (nose2.loader.ModuleImportFailure) ... ERROR

======================================================================
ERROR: test_ipycache (nose2.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_ipycache
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/nose2/plugins/loader/discovery.py", line 201, in _find_tests_in_file
    module = util.module_from_name(module_name)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/nose2/util.py", line 77, in module_from_name
    __import__(name)
  File "/home/runner/work/ipycache/ipycache/test_ipycache.py", line 19, in <module>
    from nose.tools import raises, assert_raises
ModuleNotFoundError: No module named 'nose'

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
Error: Process completed with exit code 1.
mbrukman commented 2 years ago

Turns out, we don't need to migrate from nose to nose2 because Python's standard library unittest has all the functionality we need at this time, so we can reduce our set of dependencies by rewriting our tests to be in the Python unittest style, and simplify our test setup, which should speed up our CI due to having fewer dependencies.