예제 #1
0
 def __init__(self, testPlan, flavours, testFactory):
     # Check test plan
     if (not os.path.exists(testPlan)) or (not os.path.isfile(testPlan)) \
        or (not testPlan.endswith('.rtf')):
         raise TesterError(WRONG_TEST_PLAN)
     self.testPlan = testPlan
     self.testFolder = os.path.abspath(os.path.dirname(testPlan))
     # Check flavours
     if (not isinstance(flavours, list)) and \
        (not isinstance(flavours, tuple)):
         raise TesterError(FLAVOURS_NOT_LIST)
     for flavour in flavours:
         if not isinstance(flavour, str):
             raise TesterError(FLAVOUR_NOT_STRING)
     self.flavours = flavours
     self.flavour = None
     # Check test factory
     if not issubclass(testFactory, TestFactory):
         raise TesterError(WRONG_TEST_FACTORY)
     self.testFactory = testFactory
     self.getOptions()
     self.report = TestReport('%s/Tester.report.txt' % self.testFolder,
                              self.verbose)
     self.report.say('Parsing RTF file... ')
     t1 = time.time()
     self.tables = RtfTablesParser(testPlan).parse()
     t2 = time.time() - t1
     self.report.say('Done in %d seconds' % t2)
     self.config = None
     ext = ''
     if self.flavour:
         ext = '.%s' % self.flavour
     configTableName = 'Configuration%s' % ext
     if configTableName in self.tables:
         self.config = self.tables[configTableName].asDict()
     self.tempFolder = os.path.join(self.testFolder, 'temp')
     if os.path.exists(self.tempFolder):
         FolderDeleter.delete(self.tempFolder)
     self.nbOfTests = 0
     self.nbOfSuccesses = 0
     self.nbOfIgnoredTests = 0