コード例 #1
0
		def unitTesting(codeGen):
			# Create the class suite
			first = True
			testing = []
			for test in self._inlineTests:
				if not first:
					testing.append( Schema.BlankLine() )
					testing.append( Schema.BlankLine() )
				testing.append( test._createTestClass( codeGen ) )
				first = False

			testing.append( Schema.BlankLine() )
			testing.append( Schema.BlankLine() )

			for test in self._inlineTests:
				testAst = codeGen.embeddedValue( test )
				testing.append( Schema.ExprStmt( expr=Schema.Call( target=Schema.AttributeRef( target=testAst, name='_registerTestClass' ), args=[ Schema.Load( name=test._className ) ] ) ) )

			selfAST = codeGen.embeddedValue( self )
			moduleAST = codeGen.embeddedValue( codeGen.module )
			globalsAST = Schema.Call( target=Schema.Load( name='globals' ), args=[] )
			localsAST = Schema.Call( target=Schema.Load( name='locals' ), args=[] )
			testing.append( Schema.ExprStmt( expr=Schema.Call( target=Schema.AttributeRef( target=selfAST, name='runTests' ), args=[] ) ) )
			testing.append( Schema.ExprStmt( expr=Schema.Call( target=Schema.AttributeRef( target=selfAST, name='_registerScope' ), args=[ moduleAST, globalsAST, localsAST ] ) ) )

			return Schema.PythonSuite( suite=testing )
コード例 #2
0
	def _createTestClassBodyStmts(self, codeGen, testedBlock):
		stmts = []
		first = True
		for test in self._tests:
			if not first:
				stmts.append( Schema.BlankLine() )
			test._regsiterTestTable( self )
			stmts.append( test._createMethodAST( codeGen ) )
			first = False
		return stmts