def test_get_details_success(self): parser = pysubunit.details.SimpleDetailsParser(None) expected = {} expected['message'] = content.Content( content_type.ContentType("text", "plain"), lambda: [compat._b("")]) found = parser.get_details("success") self.assertEqual(expected, found)
def _look_for_content(self, line): if line == "]\n": self._state.endDetails() return # TODO error handling field, value = line[:-1].split(' ', 1) main, sub = value.split('/') self._content_type = content_type.ContentType(main, sub) self._parse_state = self._get_name
def get_details(self, style=None): result = {} if not style: # We know that subunit/testtools serialise [] formatted # tracebacks as utf8, but perhaps we need a ReplacingContent # or something like that. result['traceback'] = content.Content( content_type.ContentType("text", "x-traceback", {"charset": "utf8"}), lambda: [self._message]) else: if style == 'skip': name = 'reason' else: name = 'message' result[name] = content.Content( content_type.ContentType("text", "plain"), lambda: [self._message]) return result
def _look_for_content(self, line): if line == end_marker: self._state.endDetails() return # TODO error handling field, value = line[:-1].decode('utf8').split(' ', 1) try: main, sub = value.split('/') except ValueError: raise ValueError("Invalid MIME type %r" % value) self._content_type = content_type.ContentType(main, sub) self._parse_state = self._get_name
def test_get_details(self): parser = pysubunit.details.SimpleDetailsParser(None) expected = {} expected['traceback'] = content.Content( content_type.ContentType("text", "x-traceback", {'charset': 'utf8'}), lambda: [compat._b("")]) found = parser.get_details() self.assertEqual(expected.keys(), found.keys()) self.assertEqual(expected['traceback'].content_type, found['traceback'].content_type) self.assertEqual( compat._b('').join(expected['traceback'].iter_bytes()), compat._b('').join(found['traceback'].iter_bytes()))
def test_parts(self): parser = pysubunit.details.MultipartDetailsParser(None) parser.lineReceived(compat._b("Content-Type: text/plain\n")) parser.lineReceived(compat._b("something\n")) parser.lineReceived(compat._b("F\r\n")) parser.lineReceived(compat._b("serialised\n")) parser.lineReceived(compat._b("form0\r\n")) expected = {} expected['something'] = content.Content( content_type.ContentType("text", "plain"), lambda: [compat._b("serialised\nform")]) found = parser.get_details() self.assertEqual(expected.keys(), found.keys()) self.assertEqual(expected['something'].content_type, found['something'].content_type) self.assertEqual( compat._b('').join(expected['something'].iter_bytes()), compat._b('').join(found['something'].iter_bytes()))
def addSuccess(self, test, details=None): test = self._add_prefix(test) xfail_reason = find_in_list(self.expected_failures, test.id()) if xfail_reason is not None: self.uxsuccess_added += 1 self.total_uxsuccess += 1 if details is None: details = {} details['reason'] = content.Content( content_type.ContentType("text", "plain", {"charset": "utf8"}), lambda: xfail_reason) self._ops.addUnexpectedSuccess(test, details) if self.output: self._ops.output_msg(self.output) if self.fail_immediately: raise ImmediateFail() else: self._ops.addSuccess(test, details) self.output = None