def get_attributes(self, include_label=False, include_elapsed=False, exclude_empty=False, values_as_strings=False, html_escape=False): attrs = {'pass': self.passed, 'fail': self.failed} attrs.update(self._get_custom_attrs()) if include_label: attrs['label'] = self.name if include_elapsed: attrs['elapsed'] = elapsed_time_to_string(self.elapsed, include_millis=False) if exclude_empty: attrs = dict((k, v) for k, v in attrs.items() if v != '') if values_as_strings: attrs = dict((k, unicode(v)) for k, v in attrs.items()) if html_escape: attrs = dict((k, self._html_escape(v)) for k, v in attrs.items()) return attrs
def _convert_to_timer(self, seconds, millis=True): return elapsed_time_to_string(seconds * 1000, include_millis=millis)