コード例 #1
0
ファイル: TestRunner.py プロジェクト: pythoncapstone/capstone
	def getResults(self):
		tests = self.unitTests.split('\n')
		testResults = {}
		for test in tests:
			if  len(str(test)) > 0:
				try:
					testResults[test] = self.__runTest(self.methodBody, test)
				except Exception, e:
					testResults[test] = PythonLib.parseExceptionMessage(e)
コード例 #2
0
	def __runFile(self):
		PythonLib.ensureDirectoryExists(self.USER_FILE_PATH)
		outputFromDebugger = open(self.USER_FILE_PATH + self.userID + 'ResultFile.txt', 'w+')
		inputForDebugger = io.StringIO(unicode(self.pythonFileBuilder.getPdcInstructions(self.stepNumber)))
		#print str(self.pythonFileBuilder.getPdcInstructions(self.stepNumber))
		debugger = pdb.Pdb(completekey='tab', stdin=inputForDebugger, stdout=outputFromDebugger)
		self.userCodeException = ''

		#generate the result file
		try:
			debugger.run('import ' + self.userCodeFilePath, {}, {})
			fileParser = FileParser.FileParser(self.USER_FILE_PATH + self.userID + 'ResultFile.txt')
			self.currentLineInUserCode = fileParser.get_current_line()
			#print '\n \n TEST: ' , fileParser.wrapper_Function_Counter , '\n \n'

		#if there was an exception, we print that out instead
		except Exception, e:
			print "\n\n__runFile = " + str(e) + "\n\n"
			self.userCodeException = PythonLib.parseExceptionMessage(e)
			# Exception line number is off by eight
			self.currentLineInUserCode = PythonLib.parseExceptionLineNumber(e)-8