Hide TestRecord and StreamToTestRecord
While they are probably OK to be exposed, let's keep this patch minimal & not news-worthy
This commit is contained in:
@@ -634,7 +634,7 @@ class StreamTagger(CopyStreamResult):
|
||||
super(StreamTagger, self).status(*args, **kwargs)
|
||||
|
||||
|
||||
class TestRecord(PClass):
|
||||
class _TestRecord(PClass):
|
||||
"""Representation of a test."""
|
||||
|
||||
"""The test id."""
|
||||
@@ -679,8 +679,8 @@ class TestRecord(PClass):
|
||||
* tags: The tags for the test. A set of unicode strings.
|
||||
* details: A dict of file attachments - ``testtools.content.Content``
|
||||
objects.
|
||||
* status: One of the StreamResult status codes (including inprogress) or
|
||||
'unknown' (used if only file events for a test were received...)
|
||||
* status: One of the StreamResult status codes (including inprogress)
|
||||
or 'unknown' (used if only file events for a test were received...)
|
||||
* timestamps: A pair of timestamps - the first one received with this
|
||||
test id, and the one in the event that triggered the notification.
|
||||
Hung tests have a None for the second end event. Timestamps are not
|
||||
@@ -771,36 +771,36 @@ _status_map = pmap({
|
||||
})
|
||||
|
||||
|
||||
class StreamToTestRecord(StreamResult):
|
||||
class _StreamToTestRecord(StreamResult):
|
||||
"""A specialised StreamResult that emits a callback as tests complete.
|
||||
|
||||
Top level file attachments are simply discarded. Hung tests are detected
|
||||
by stopTestRun and notified there and then.
|
||||
|
||||
The callback is passed a ``TestRecord`` object.
|
||||
The callback is passed a ``_TestRecord`` object.
|
||||
|
||||
Only the most recent tags observed in the stream are reported.
|
||||
"""
|
||||
|
||||
def __init__(self, on_test):
|
||||
"""Create a StreamToTestRecord calling on_test on test completions.
|
||||
"""Create a _StreamToTestRecord calling on_test on test completions.
|
||||
|
||||
:param on_test: A callback that accepts one parameter:
|
||||
a ``TestRecord`` object describing a test.
|
||||
a ``_TestRecord`` object describing a test.
|
||||
"""
|
||||
super(StreamToTestRecord, self).__init__()
|
||||
super(_StreamToTestRecord, self).__init__()
|
||||
self.on_test = on_test
|
||||
if parse_mime_type is None:
|
||||
raise ImportError("mimeparse module missing.")
|
||||
|
||||
def startTestRun(self):
|
||||
super(StreamToTestRecord, self).startTestRun()
|
||||
super(_StreamToTestRecord, self).startTestRun()
|
||||
self._inprogress = {}
|
||||
|
||||
def status(self, test_id=None, test_status=None, test_tags=None,
|
||||
runnable=True, file_name=None, file_bytes=None, eof=False,
|
||||
mime_type=None, route_code=None, timestamp=None):
|
||||
super(StreamToTestRecord, self).status(
|
||||
super(_StreamToTestRecord, self).status(
|
||||
test_id, test_status,
|
||||
test_tags=test_tags, runnable=runnable, file_name=file_name,
|
||||
file_bytes=file_bytes, eof=eof, mime_type=mime_type,
|
||||
@@ -836,7 +836,7 @@ class StreamToTestRecord(StreamResult):
|
||||
return case
|
||||
|
||||
def stopTestRun(self):
|
||||
super(StreamToTestRecord, self).stopTestRun()
|
||||
super(_StreamToTestRecord, self).stopTestRun()
|
||||
while self._inprogress:
|
||||
case = self._inprogress.popitem()[1]
|
||||
self.on_test(case.got_timestamp(None))
|
||||
@@ -846,7 +846,7 @@ class StreamToTestRecord(StreamResult):
|
||||
return
|
||||
key = (test_id, route_code)
|
||||
if key not in self._inprogress:
|
||||
self._inprogress[key] = TestRecord.create(test_id, timestamp)
|
||||
self._inprogress[key] = _TestRecord.create(test_id, timestamp)
|
||||
return key
|
||||
|
||||
|
||||
@@ -879,16 +879,16 @@ class StreamToDict(StreamResult):
|
||||
# class, and have this inherit from that.
|
||||
|
||||
def __init__(self, on_test):
|
||||
"""Create a StreamToTestRecord calling on_test on test completions.
|
||||
"""Create a _StreamToTestRecord calling on_test on test completions.
|
||||
|
||||
:param on_test: A callback that accepts one parameter:
|
||||
a ``TestRecord`` object describing a test.
|
||||
a dictionary describing a test.
|
||||
"""
|
||||
super(StreamToDict, self).__init__()
|
||||
self._hook = StreamToTestRecord(self._handle_test)
|
||||
self._hook = _StreamToTestRecord(self._handle_test)
|
||||
# XXX: Not clear whether its part of the supported interface for
|
||||
# self.on_test to be the passed-in on_test. If not, we could reduce
|
||||
# the boilerplate by subclassing StreamToTestRecord.
|
||||
# the boilerplate by subclassing _StreamToTestRecord.
|
||||
self.on_test = on_test
|
||||
|
||||
def _handle_test(self, test_record):
|
||||
@@ -913,7 +913,7 @@ def test_dict_to_case(test_dict):
|
||||
:param test_dict: A test dict as generated by StreamToDict.
|
||||
:return: A PlaceHolder test object.
|
||||
"""
|
||||
return TestRecord(
|
||||
return _TestRecord(
|
||||
id=test_dict['id'],
|
||||
tags=test_dict['tags'],
|
||||
details=test_dict['details'],
|
||||
@@ -932,7 +932,7 @@ class StreamSummary(StreamResult):
|
||||
|
||||
def __init__(self):
|
||||
super(StreamSummary, self).__init__()
|
||||
self._hook = StreamToTestRecord(self._gather_test)
|
||||
self._hook = _StreamToTestRecord(self._gather_test)
|
||||
self._handle_status = {
|
||||
'success': self._success,
|
||||
'skip': self._skip,
|
||||
@@ -1688,8 +1688,8 @@ class StreamToExtendedDecorator(StreamResult):
|
||||
# ExtendedToOriginalDecorator takes care of thunking details back to
|
||||
# exceptions/reasons etc.
|
||||
self.decorated = ExtendedToOriginalDecorator(decorated)
|
||||
# StreamToTestRecord buffers and gives us individual tests.
|
||||
self.hook = StreamToTestRecord(self._handle_tests)
|
||||
# _StreamToTestRecord buffers and gives us individual tests.
|
||||
self.hook = _StreamToTestRecord(self._handle_tests)
|
||||
|
||||
def status(self, test_id=None, test_status=None, *args, **kwargs):
|
||||
if test_status == 'exists':
|
||||
|
||||
Reference in New Issue
Block a user