def summarize(self, fixture): totalString = "total counts" runCounts = self.summary.get(totalString) if not runCounts: runCounts = Counts() runCounts.tally(fixture.counts) self.summary[totalString] = runCounts
def summarize(self, fixture, path): fixture.summary["input file"] = os.path.abspath(path) fixture.summary["input update"] = time.ctime(os.path.getmtime(path)) runCounts = self.summary.get("counts run") if not runCounts: runCounts = Counts() self.summary["counts run"] = runCounts runCounts.tally(fixture.counts)
def __init__(self): ColumnFixture.__init__(self) self.fileName = "" self.wiki = 0 self.input = "" self.tables = None self.fixture = None self.runCounts = Counts() self.footnote = None self.fileCell = None
class TextFixture(object): ''' classdocs ''' counts = Counts() summary = {} results = {} testCaseId = 1 readedLines = 0 urlpath = '' def __init__(self): pass def doTextTest(self, textFileName, reportname): self.textFileName = textFileName self.reportname = reportname file_object = open(self.textFileName, 'r') try: fixturePath = str(file_object.readline()) fixturePath = self.strip(fixturePath) self.urlpath = self.strip(file_object.readline()) if self.urlpath.find('url:') > -1: self.urlpath = self.urlpath.split(':')[-1] self.readedLines += 1 else: self.urlpath = '' print fixturePath if fixturePath.find( 'fixture' ) == -1: # if have not fixture row, use default fixture fixturePath = 'fixture.TextFixture' else: self.readedLines += 1 clas = fixturePath.split('.')[-1] # fix for illegal Java trick in AllFiles. Frankly, I like it! i = fixturePath.split('$') try: if len(i) == 1: exec 'import ' + fixturePath # # test class method exec 'fixture = ' + fixturePath + '.' + clas + '()' else: exec "import %s" % (i[0], ) exec "fixture = %s.%s()" % (i[0], i[1]) except ImportError, e: Log.exception(e) print 'fixturePath does not exists' print 'system exit' return fixture.fixturePath = fixturePath fixture.textFileName = self.textFileName fixture.reportname = self.reportname fixture.readedLines = self.readedLines fixture.urlpath = self.urlpath fixture.runTest() finally:
def mark(self, row): official = self.counts self.counts = Counts() cell = row.parts.more if official.wrong + official.exceptions > 0: self.wrong(cell) else: self.right(cell) self.counts = official
class ExampleTests(ColumnFixture): fileName = "" wiki = 0 _typeDict = { "fileName": "String", "file.renameTo": "fileName", "wiki": "Boolean" } def __init__(self): ColumnFixture.__init__(self) self.fileName = "" self.wiki = 0 self.input = "" self.tables = None self.fixture = None self.runCounts = Counts() self.footnote = None self.fileCell = None def run(self): newFileName = "fat/Documents/" + self.fileName inFile = open(newFileName, 'r') theTest = inFile.read() inFile.close() self.fixture = Fixture() self.footnote = None if self.wiki: self.tables = Parse(text=theTest, tags=("wiki", "table", "tr", "td")) else: self.tables = Parse(text=theTest, tags=("table", "tr", "td")) self.fixture.doTables(self.tables) self.runCounts.tally(self.fixture.counts) self.summary["counts run"] = self.runCounts _typeDict["right_"] = "Int" _typeDict["right.renameTo"] = "right_" def right_(self): self.run() return self.fixture.counts.right _typeDict["wrong_"] = "Int" _typeDict["wrong.renameTo"] = "wrong_" def wrong_(self): return self.fixture.counts.wrong _typeDict["ignores"] = "Int" def ignores(self): return self.fixture.counts.ignores _typeDict["exceptions"] = "Int" def exceptions(self): return self.fixture.counts.exceptions def doRow(self, row): self.fileCell = row.leaf() ColumnFixture.doRow(self, row) def wrong(self, cell, actual=None, escape=True): # super(ExampleTests, self) ColumnFixture.wrong(self, cell, actual=actual, escape=escape) if self.footnote == None: self.footnote = self.tables.footnote() self.fileCell.addToBody(self.footnote)
class ExampleTests(ColumnFixture): fileName = "" wiki = 0 _typeDict = {"fileName": "String", "file.renameTo": "fileName", "wiki": "Boolean"} def __init__(self): ColumnFixture.__init__(self) self.fileName = "" self.wiki = 0 self.input = "" self.tables = None self.fixture = None self.runCounts = Counts() self.footnote = None self.fileCell = None def run(self): newFileName = "fat/Documents/" + self.fileName inFile = open(newFileName, 'r') theTest = inFile.read() inFile.close() self.fixture = Fixture() self.footnote = None if self.wiki: self.tables = Parse(text=theTest, tags=("wiki", "table", "tr", "td")) else: self.tables = Parse(text=theTest, tags=("table", "tr", "td")) self.fixture.doTables(self.tables) self.runCounts.tally(self.fixture.counts) self.summary["counts run"] = self.runCounts _typeDict["right_"] = "Int" _typeDict["right.renameTo"] = "right_" def right_(self): self.run() return self.fixture.counts.right _typeDict["wrong_"] = "Int" _typeDict["wrong.renameTo"] = "wrong_" def wrong_(self): return self.fixture.counts.wrong _typeDict["ignores"] = "Int" def ignores(self): return self.fixture.counts.ignores _typeDict["exceptions"] = "Int" def exceptions(self): return self.fixture.counts.exceptions def doRow(self, row): self.fileCell = row.leaf() ColumnFixture.doRow(self, row) def wrong(self, cell, actual = None, escape=True): # super(ExampleTests, self) ColumnFixture.wrong(self, cell, actual = actual, escape = escape) if self.footnote == None: self.footnote = self.tables.footnote() self.fileCell.addToBody(self.footnote)