Skip to content

2.9.0 regression: _StringException traceback leaks into error reports for stdlib unittest.TestResult consumers #606

@jelmer

Description

@jelmer

testtools 2.9.0 leaks its own internal traceback into the error string seen by stdlib unittest.TestResult consumers of ExtendedToOriginalDecorator. 2.8.x reported just testtools.testresult.real._StringException; 2.9.0 reports a full traceback pointing into testtools/testresult/real.py.

import unittest
from io import BytesIO
import subunit

client = unittest.TestResult()
subunit.TestProtocolServer(client).readFrom(BytesIO(b"test x\nerror x\n"))
print(client.errors[0][1])

2.8.x:

testtools.testresult.real._StringException

2.9.0:

Traceback (most recent call last):
  File ".../testtools/testresult/real.py", line 1991, in addError
    self.decorated.addError(test, details=details)  # type: ignore[call-arg]
  File ".../unittest/result.py", line 17, in inner
    return method(self, *args, **kw)
TypeError: TestResult.addError() got an unexpected keyword argument 'details'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".../testtools/testresult/real.py", line 2118, in _details_to_exc_info
    raise _StringException(_details_to_str(details, special="traceback"))
testtools.testresult.real._StringException

Breaks subunit CI: https://github.com/testing-cabal/subunit/actions/runs/24862737296/job/72791864617?pr=102.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions