How to build conda package fail on errors on run_test.py
I am creating a conda recipe and added run_test.py. These are unittest classes. Unfortunately, when there are errors, the package is still generated.
My question is how to tell conda that the test failed and it shouldn't continue building the package.
run_test.py contains:
suit = unittest.TestLoader (). detect ("../tests/unitTest") #, pattern = "test [AP] [la] * [sr] .py") unittest.TextTestRunner (verbosity = 2) .run (suit)
I am adding files to meta.yaml
test: files: - .. / tests / unittest /
This is the conclusion:
Ran 16 tests in 2.550s
FAILED (errors = 5)
===== PACKAGE-NAME-None-np18py27_0 OK ====
I want to stop the build
source to share
In run_test.py
you can call unittest.main()
by doing the following:
if __name__ == "__main__":
unittest.main()
The conda build process will automatically fail if the tests fail. This link helps to demonstrate: calling the unittest main method
source to share