def __init__(self, options): if subunit is None: raise Exception("Requires subunit 0.0.5 or better") if content is None: raise Exception("Requires testtools 0.9.2 or better") self.options = options self._stream = sys.stdout self._subunit = subunit.TestProtocolClient(self._stream) # Used to track the last layer that was set up or torn down. Either # None or (layer_name, last_touched_time). self._last_layer = None self.UTC = Utc() # Content types used in the output. self.TRACEBACK_CONTENT_TYPE = content.ContentType( 'text', 'x-traceback', dict(language='python', charset='utf8')) self.PROFILE_CONTENT_TYPE = content.ContentType( 'application', 'x-binary-profile') self.PLAIN_TEXT = content.ContentType('text', 'plain', {'charset': 'utf8'})
def __init__(self, options, stream=None): if subunit is None: raise Exception('Requires subunit 0.0.11 or better') if testtools is None: raise Exception('Requires testtools 0.9.30 or better') self.options = options if stream is None: stream = sys.stdout self._stream = stream self._subunit = self._subunit_factory(self._stream) # Used to track the last layer that was set up or torn down. Either # None or (layer_name, last_touched_time). self._last_layer = None self.UTC = Utc() # Content types used in the output. self.TRACEBACK_CONTENT_TYPE = ContentType( 'text', 'x-traceback', {'language': 'python', 'charset': 'utf8'}) self.PROFILE_CONTENT_TYPE = ContentType( 'application', 'x-binary-profile') self.PLAIN_TEXT = ContentType('text', 'plain', {'charset': 'utf8'})
def now(): """ A timestamp suitable for subunit """ return datetime.datetime.now(tz=Utc())