You can move the tests to a separate file, like this:

foo.py ← our module
foo_test.py ← its unit test