def getCoverageData(self, testCaseSeq): c = self.conn.cursor() SELECT_SQL = """ SELECT file, line FROM {0} WHERE case_seq = {1} """.format(TestCaseDB.CASE_COVERAGE_TABLE_NAME, testCaseSeq) c.execute(SELECT_SQL) result = {} row = c.fetchone() while row: scriptName = row[0] lineSet = set(string.split(row[1])) rangeSet = [] for aLine in lineSet: rangeSet.append(Range.parseFrom(aLine)) rangeSet.sort() covInfo = CoverageRange(scriptName, rangeSet) result[scriptName] = covInfo row = c.fetchone() return result
class RangeTest(unittest.TestCase): def setUp(self): self.aRange = Range(1, 10) def testInit(self): self.assertEqual(self.aRange.getFirst(), 1) self.assertEqual(self.aRange.getLast(), 10) def testInRange(self): self.assertTrue(self.aRange.contains(1)) self.assertTrue(self.aRange.contains(10)) self.assertTrue(self.aRange.contains(5)) self.assertFalse(self.aRange.contains(0)) self.assertFalse(self.aRange.contains(11))
def setUp(self): self.aRange = Range(1, 10)