Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlosDomingues/62cd70e698b7df9dea4ad0df0ee2e12d to your computer and use it in GitHub Desktop.
Save CarlosDomingues/62cd70e698b7df9dea4ad0df0ee2e12d to your computer and use it in GitHub Desktop.
Making a library run unittests correctly for any Python > 2.6
import sys
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
sys.path.insert(0, "./<my_module>")
from <my_submodule> import fun1, fun2
else:
from <my_module>.<my_submodule> import fun1, fun2
For Python 2 / 3:
python -m unittest discover
For python 2.6 you need to run each test file:
python ./test/test_<my_submodule>.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment