Skip to main content

RemoteTestResult

Extend unittest.TestResult to record events in the child processes so they can be replayed in the parent process. Events include things like which tests succeeded or failed.

Attributes

AttributeTypeDescription
failures[DummyList](dummylist.md?sid=django_test_runner_dummylist) = DummyList()A dummy list used to replace standard failure storage to reduce memory usage in child processes.
errors[DummyList](dummylist.md?sid=django_test_runner_dummylist) = DummyList()A dummy list used to replace standard error storage to reduce memory usage in child processes.
skipped[DummyList](dummylist.md?sid=django_test_runner_dummylist) = DummyList()A dummy list used to replace standard skip storage to reduce memory usage in child processes.
expectedFailures[DummyList](dummylist.md?sid=django_test_runner_dummylist) = DummyList()A dummy list used to replace standard expected failure storage to reduce memory usage in child processes.
unexpectedSuccesses[DummyList](dummylist.md?sid=django_test_runner_dummylist) = DummyList()A dummy list used to replace standard unexpected success storage to reduce memory usage in child processes.
eventslist = []A list of recorded test event tuples used to replay results in the parent process.
test_indexintThe zero-based index of the current test being run, derived from the total number of tests run.

Constructor

Signature

def RemoteTestResult(
*args: any,
**kwargs: any
)

Parameters

NameTypeDescription
*argsanyVariable length argument list passed to the parent unittest.TestResult constructor.
**kwargsanyArbitrary keyword arguments passed to the parent unittest.TestResult constructor.

Methods


test_index()

@classmethod
def test_index() - > int

Calculates the current test index based on the total number of tests run.

Returns

TypeDescription
intThe zero-based index of the current test.

check_picklable()

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

Verifies that exception info can be pickled, providing helpful guidance or warnings if serialization fails.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that raised the exception.
errtupleThe sys.exc_info() tuple containing the exception type, value, and traceback.

check_subtest_picklable()

@classmethod
def check_subtest_picklable(
test: unittest.TestCase,
subtest: unittest.TestCase
)

Validates that a subtest object is picklable to ensure it can be passed back from a worker process.

Parameters

NameTypeDescription
testunittest.TestCaseThe parent test case.
subtestunittest.TestCaseThe subtest instance to validate.

startTestRun()

@classmethod
def startTestRun()

Signals the beginning of a test run and records the event.


stopTestRun()

@classmethod
def stopTestRun()

Signals the completion of a test run and records the event.


startTest()

@classmethod
def startTest(
test: unittest.TestCase
)

Records the start of an individual test case.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that is starting.

stopTest()

@classmethod
def stopTest(
test: unittest.TestCase
)

Records the completion of an individual test case.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that has finished.

addDuration()

@classmethod
def addDuration(
test: unittest.TestCase,
elapsed: float
)

Logs the execution duration for a specific test.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that was timed.
elapsedfloatThe time in seconds taken to run the test.

addError()

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

Records an error event, ensuring the error is picklable for parallel processing.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case or error holder where the error occurred.
errtupleThe exception information tuple.

addFailure()

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

Records a test failure event after verifying the failure details can be pickled.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that failed.
errtupleThe exception information tuple representing the failure.

addSubTest()

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

Records a subtest result if an error occurred, verifying picklability of both the error and the subtest.

Parameters

NameTypeDescription
testunittest.TestCaseThe parent test case.
subtestunittest.TestCaseThe specific subtest instance.
errtupleThe exception info if the subtest failed, or None if it succeeded.

addSuccess()

@classmethod
def addSuccess(
test: unittest.TestCase
)

Records a successful test completion event.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that passed.

addSkip()

@classmethod
def addSkip(
test: unittest.TestCase,
reason: string
)

Records a skipped test event along with the reason for skipping.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that was skipped.
reasonstringThe explanation provided for skipping the test.

addExpectedFailure()

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

Records an expected failure, optionally stripping the traceback if tblib is not available to ensure picklability.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that failed as expected.
errtupleThe exception information tuple.

addUnexpectedSuccess()

@classmethod
def addUnexpectedSuccess(
test: unittest.TestCase
)

Records an event where a test decorated with expectedFailure actually passed.

Parameters

NameTypeDescription
testunittest.TestCaseThe test case that unexpectedly succeeded.

wasSuccessful()

@classmethod
def wasSuccessful() - > boolean

Tells whether or not this result was a success.

Returns

TypeDescription
booleanTrue if no errors, failures, subtest failures, or unexpected successes were recorded; False otherwise.