Ich versuche, einen HTML-Bericht für meine Einheit Test Script zu erstellen, Wenn ich versuche, den Code auszuführen, es wirft, dieser Fehler AttributeError: 'str' object has no attribute 'decode'
Attribute: ‚str‘ Objekt hat kein Attribut ‚decode‘ Latin-1
Unten ist der Teil des Codes, wo es Fehler zeigt: -
if isinstance(o,str):
# TODO: some problem with 'string_escape': it escape \n and mess up formating
# uo = unicode(o.encode('string_escape'))
uo = o.decode('latin-1')
else:
uo = o
if isinstance(e,str):
# TODO: some problem with 'string_escape': it escape \n and mess up formating
# ue = unicode(e.encode('string_escape'))
ue = e.decode('latin-1')
else:
ue = e
script = self.REPORT_TEST_OUTPUT_TMPL % dict(
id = tid,
output = saxutils.escape(uo+ue),
)
der obige Code ist aus HTMLTestRunner.py
Datei. Bitte helfen Sie dieses Problem zu debuggen.
richtige Methode ist –