unittests: move test_minnn.py to using unittests instead of manually written tests #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves the
minnnrepo to using Python's inbuiltunittestsmodule to do testing, along with some complementary changes. In particular, this PR creates aTestCaseunder which all 9 of the old tests appear. It also removes the use ofassertstatements, instead moving tounittest'sself.assert*calls for individual values, andnp.testing.assert_is_allclosecalls 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 tounittestare 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, orpython test_minnn.py) or with the unittest runners found in many IDEs (tested in PyCharm).Example screenshot of running from console:
