I'm using pytest with bazel. To get bazel to pick up the fact that a pytest test has failed you need to put this at the end of every *_test.py file:
if __name__ == "__main__":
sys.exit(pytest.main([__file__]))
(See bazel-contrib/rules_python#240 )
It would be nice if this tool had an option to change the unittest-based snippet
if __name__ == "__main__":
unittest.main()
with the pytest one.