My solution is gory but practical.
in setup.py I added:
def test(): """let's script the command line python -munittest discover""" loader= unittest.TestLoader() suite=loader.discover(".", "test_.*.py") runner=unittest.TextTestRunner() result=runner.run(suite) if not result.wasSuccessful(): raise Exception( "Test Failed: Aborting install") print("#### Test passed") if "install" in sys.argv or "bdist_egg" in sys.argv or "sdist" in sys.argv: test()
And since practicality beats purity...
Still wondering if it is a bad idea
Okay, I test my packages before deploying, okay, there is tox. But no test can make as much variations as what users have as an environment. Even though I don't find it nice, at least it has the authoritative psycho-rigid behaviour I want.
Just like in Perl, if it does not pass the tests, it should not be installed.
I still wish I could:
- make an autoreport tool (calling a REST server) to know how reliable are my packages, and which OSes/python versions have problems;
- have a tool that let user interract with ticketting system;
- bypass the tests with a --force flag, and call the test suite in a unified way once the package is installed.