Skip to main content

PDBDebugResult

Custom result class that triggers a PDB session when an error or failure occurs.

Attributes

AttributeTypeDescription
bufferboolean = FalseA boolean flag that, when set to False, disables the buffering of standard output and error streams during a debug session.

Methods


addError()

@classmethod
def addError(
test: unittest.TestCase,
err: tuple
)

Records a test error and immediately triggers a post-mortem PDB debugging session for the raised exception.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case instance that encountered an error
errtupleA tuple containing the exception type, value, and traceback information

addFailure()

@classmethod
def addFailure(
test: unittest.TestCase,
err: tuple
)

Records a test failure and immediately triggers a post-mortem PDB debugging session for the failure exception.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case instance that failed its assertions
errtupleA tuple containing the failure exception type, value, and traceback information

addSubTest()

@classmethod
def addSubTest(
test: unittest.TestCase,
subtest: unittest.TestCase,
err: tuple
)

Handles the result of a subtest and triggers a PDB session if the subtest encountered an error or failure.

Parameters

NameTypeDescription
testunittest.TestCaseThe parent test case instance
subtestunittest.TestCaseThe specific subtest instance being executed
errtupleThe exception information if the subtest failed, or None if it passed

debug()

@classmethod
def debug(
error: tuple
)

Restores standard output and launches the PDB post-mortem debugger using the provided error information.

Parameters

NameTypeDescription
errortupleThe exception details used to initialize the debugger, typically containing (type, value, traceback)