# Unittest: Fail if zero tests were discovered

**URL:** <https://discuss.python.org/t/unittest-fail-if-zero-tests-were-discovered/21498>\
**Category:** Ideas\
**Created:** [November 29, 2022, 12:44am UTC](https://discuss.python.org/t/unittest-fail-if-zero-tests-were-discovered/21498 "2022-11-29T00:44:46Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![stefanor](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/stefanor/32/9984_2.png) [@stefanor](https://discuss.python.org/u/stefanor)\
**Post date:** [November 29, 2022, 10:51am UTC](https://discuss.python.org/t/unittest-fail-if-zero-tests-were-discovered/21498/5 "2022-11-29T10:51:36Z")

</div>

> [@tjreedy](#):
>
> I am sure that this has been discussed before, but I could not find an issue.

Thanks, I had searched and not found it, either 🙂

> [@gpshead](#):
>
> But doing it from the unittest module seems difficult. When do you trigger it and how?

My proposal would be to do it in unittest’s runner (the `unittest.main` module). I don’t think it really makes sense to do it in the test suite itself. The problem we are chasing is that we haven’t found the suite.

In the specific use-case for Debian, we would like to be able to have this behaviour at scale. Not be something we have to patch into every package’s test suite, separately. We have common code that most Python packages use to run their test suites, so we could make that pass an extra argument. Packages without test suites that are currently running 0 tests successfully would have to explicitly disable tests, which seems like the right way to go, these days. I guess we could also look at changing our default test runner from unittest to pytest, to achieve this, but that brings in extra dependencies, at build time, everywhere, which isn’t great.

---

_[View the full topic](https://discuss.python.org/t/unittest-fail-if-zero-tests-were-discovered/21498)._
