Esempio n. 1
0
def reCalcCoverageInfo(caseInfo):

    rcFilename = genCoverageRcFileName(caseInfo)

    coverageXmlFile = 'coverage_%d.xml' % caseInfo.getSeq()

    # generate coverage report
    os.system("coverage xml --rcfile=%s -o %s" % (rcFilename, coverageXmlFile))

    # parse the coverage report
    # default report file name is 'coverage.xml'
    fileContent = open(coverageXmlFile, 'r').read()

    coverageInfo = Parser.parse(fileContent)

    emptyLines = {}
    for scriptName in coverageInfo.keys():
        # get empty lines of each script name
        lines = EmptyLineFinder.findEmptyLines(scriptName)
        emptyLines[scriptName] = lines

    coverageInfo = Parser.mergeEmptyLines(coverageInfo, emptyLines)

    os.remove(rcFilename)
    os.remove(coverageXmlFile)

    return coverageInfo
    def testFind(self):

        lines = finder.findEmptyLines(EmptyLineFinderTest.FILE_NAME)

        self.assertEqual(lines, [1,2,4])