Background:
I have a bunch of tests (20+) which I cannot execute on my working machine, because they require a working CUDA environment.
So to avoid errors, I've made them conditional through a unittest.skipIf
.
Abstracting away the details, my test module looks like this:
@unittest.skipIf(os.environ.get('TEST_FANCY') != 'yes', "For fancy tests, set TEST_FANCY='yes'")
class FancyTests(unittest.TestCase):
def test_a(self):
self.assertEqual(1+1, 2)
def test_b(self):
self.assertEqual(1+2, 3)
Now when I run the tests by green
, every skipped test gets reported in a verbose fashion, polluting the output greatly, e.g.:
..ss.
Skipped test.test_fancy.FancyTests.test_a - For fancy tests, set TEST_FANCY='yes'
Skipped test.test_fancy.FancyTests.test_b - For fancy tests, set TEST_FANCY='yes'
Ran 5 tests in 0.355s using 4 processes
OK (passes=3, skips=2)
I would like the output to just summarize the results, similar to what the standard unittest runner does by default, i.e.:
..ss.
Ran 5 tests in 0.355s using 4 processes
OK (passes=3, skips=2)
While
green
reports the individual skipped tests by default, it allows to suppress these by-k
. From the docs: