Revision: 2471 Author: janne.t.harkonen Date: Thu Feb 18 04:04:38 2010 Log: Handle missing status tag in readers.
This is required so that xml fixed by tool required in issue 99 can be processed with Rebot. http://code.google.com/p/robotframework/source/detail?r=2471 Modified: /trunk/src/robot/output/readers.py ======================================= --- /trunk/src/robot/output/readers.py Thu Feb 18 04:04:14 2010 +++ /trunk/src/robot/output/readers.py Thu Feb 18 04:04:38 2010 @@ -72,6 +72,11 @@ return None +class _MissingStatus: + text = 'Broken output file' + get_attr = lambda self, name, default: 'N/A' + + class _BaseReader: def __init__(self, node): @@ -79,8 +84,14 @@ self.doc = node.get_node('doc').text except AttributeError: self.doc = '' - status = node.get_node('status') - self.status = status.get_attr('status','').upper() + try: + status = node.get_node('status') + self.status = status.get_attr('status','').upper() + except AttributeError: + # If XML was fixed for example by fixml.py, status tag may be + # missing + status = _MissingStatus() + self.status = 'FAIL' if self.status not in ['PASS','FAIL']: raise DataError("Item '%s' has invalid status '%s'" % (self.name, status))
