コード例 #1
0
ファイル: Parser.py プロジェクト: bloodlee/CoverageEx
    def parse(fileContent):
        """
        Parse the report file content
        Return the result dict (key, value) = (script name, CovInfo)

        If the fileContent is None or empty, empty dict will be return.
        """
        result = {}
        if not fileContent:
            return result

        # parse the given content
        root = ElementTree.fromstring(fileContent)

        classElements = root.findall(COV_CLASS_XPATH)
        for anElement in classElements:
            scriptName = anElement.attrib[FILENAME_PROP]
            covInfo = ScriptCovInfo(scriptName, set())

            lines = anElement.findall(LINE_RELATIVE_XPATH)
            for aLine in lines:
                if aLine.attrib[HITS_PROP] != '0':
                    covInfo.addLine(int(aLine.attrib[LINE_NUM_PROP]))
            result[scriptName] = covInfo

        return result
コード例 #2
0
    def testConstructor1(self):
        info = ScriptCovInfo("script1", set())

        self.assertEqual(info.getScriptName(), "script1")
        self.assertEqual(info.getAllLines(), set())
        self.assertEqual(info.lineCount(), 0)
コード例 #3
0
    def testConstructor2(self):
        info = ScriptCovInfo("script2", {1,1,3,4,5,5})

        self.assertEqual(info.getScriptName(), "script2")
        self.assertEqual(info.getAllLines(), {1,3,4,5})
        self.assertEqual(info.lineCount(), 4)