Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite unit tests to use Python unittest #66

Merged
merged 1 commit into from
Jan 16, 2022

Conversation

mbrukman
Copy link
Collaborator

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 #61

@mbrukman
Copy link
Collaborator Author

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!

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`.

Drop test dependency on `nose` since we no longer need it.

Change the test runner command from `nosetests` to `python -m unittest`.

Closes rossant#61
@mbrukman
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

  • Before, via nosetests: "Ran 10 tests in 0.742s"
  • After, via unittest: "Ran 10 tests in 0.008s"

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! 🎉

@mbrukman mbrukman merged commit 4042ed1 into rossant:master Jan 16, 2022
@mbrukman mbrukman deleted the update-unit-tests branch January 16, 2022 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace deprecated, unmaintained nose with another solution
1 participant