Package inca :: Module SimpleUnitReporter
[hide private]
[frames] | no frames]

Source Code for Module inca.SimpleUnitReporter

 1  from inca.Reporter import Reporter 
 2   
3 -class SimpleUnitReporter(Reporter):
4 """SimpleUnitReporter - Module for creating simple unit reporters:: 5 6 from inca.SimpleUnitReporter import SimpleUnitReporter 7 reporter = SimpleUnitReporter( 8 name = 'Reporter Name', 9 version = 0.1, 10 description = 'A really helpful reporter description', 11 url = 'http://url.to.more.reporter.info' 12 unit_name = 'What this reporter tests' 13 ) 14 15 This module is a subclass of Reporter that provides convenience methods 16 for testing the successful operation of a software package. If the test 17 completes, the report body contains:: 18 19 <unitTest> 20 <ID>unitX</ID> 21 </unitTest> 22 23 Otherwise, the exit_status of the report is set to false. 24 """ 25
26 - def __init__(self, **attributes):
27 """Class constructor that returns a new SimpleUnitReporter object. The 28 constructor supports the following parameter in addition to those 29 supported by Reporter:: 30 31 unit_name 32 the name of the unit being tested; default ''. 33 """ 34 unit_name = '' 35 if attributes.has_key('unit_name'): 36 unit_name = attributes['unit_name'] 37 del attributes['unit_name'] 38 Reporter.__init__(self, **attributes) 39 self.unit_name = unit_name 40 self.addDependency('inca.SimpleUnitReporter')
41
42 - def getUnitName(self):
43 """Return the name of the unit being tested.""" 44 return self.unit_name
45
46 - def reportBody(self):
47 """Constructs and returns the body of the reporter.""" 48 idXml = self.xmlElement('ID', 1, self.getUnitName()) 49 return self.xmlElement('unitTest', 0, idXml)
50
51 - def setUnitName(self, name):
52 """Set the name of the unit being tested to name.""" 53 self.unit_name = name
54
55 - def unitFailure(self, msg):
56 """Sets the result of this unit test to be failed with failure message 57 msg. 58 """ 59 self.setResult(0, msg)
60
61 - def unitSuccess(self):
62 """Sets the result of this unit test to be successful.""" 63 self.setResult(1)
64