zopefoundation / zope.testrunner

This package provides a flexible test runner with layer support.
https://zopetestrunner.readthedocs.io/
Other
2 stars 23 forks source link

Report / handle subtests #169

Closed gforcada closed 5 months ago

gforcada commented 6 months ago

BUG/PROBLEM REPORT / FEATURE REQUEST

The other day I learned about unittest.subTest, see docs.

Which is, partly the same as pytest.mark.parametrize.

The problem I'm seeing, is that I created a test that generated 6 subtests and they were all failing, but the output from zope.testrunner was rather unhelpful:

Running zope.testrunner.layer.UnitTests tests:
  Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
  Ran 1 tests with 3 failures, 0 errors and 0 skipped in 0.001 seconds.
Tearing down left over layers:
  Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.

It correctly reports the 3 failures, but shows no traceback at all ๐Ÿ˜•

What I did:

Create a test like:

class DummyExampleTest(unittest.TestCase):
    def test_example(self):
        data = (
            (2, 3, 5),
            (2, 3, 6),
            (2, 3, 7),
            (2, 3, 8),
        )
        for first, second, result in data:
            with self.subTest(result):
                self.assertEqual(first + second, result)

Run it with zope.testrunner -t DummyExampleTest and see the output above.

What I expect to happen:

That the 3 failures would show their traceback.

What actually happened:

No tracebacks to be seen.

What version of Python and Zope/Addons I am using:

Fedora Linux 40 Python 3.11 zope.testrunner 6.4 Zope 5.9 Plone 6.0.10

icemac commented 5 months ago

Looks like a duplicate of #91. If it is the case, please close here and add there.

gforcada commented 5 months ago

Oh right, indeed. I did not find it when searching for this ๐Ÿ˜“