minnn-assignment
minnn-assignment copied to clipboard
unittests: move test_minnn.py to using unittests instead of manually written tests
This PR moves the minnn
repo to using Python's inbuilt unittests
module to do testing, along with some complementary changes. In particular, this PR creates a TestCase
under which all 9 of the old tests appear. It also removes the use of assert
statements, instead moving to unittest
's self.assert*
calls for individual values, and np.testing.assert_is_allclose
calls for approximate array equality. This creates both better error reporting and the ability to run all tests and collect errors before the script fails.
This refactor no longer allows specifying the script path of minnn.py
: any arguments to unittest
are interpreted as paths/modules to test. I cleared this with @neubig in office hours; if it's helpful, I can add an option to specify the module for dynamic import with an environment variable.
This module can either be run as before from the console (python -m test_minnn
, or python test_minnn.py
) or with the unittest runners found in many IDEs (tested in PyCharm).
Example screenshot of running from console: