def _testInclude( self, contents1, contents2, expected ):
     tested = savingiterator.SavingIterator()
     with tools.temporaryFile( contents1 ) as contentsFile1:
         contents2 = '#include "%s"\n%s' % ( contentsFile1, contents2 )
         with tools.temporaryFile( contents2 ) as contentsFile2:
             tested.process( contentsFile2 )
     if tested.saved != expected:
         pprint.pprint( tested.saved )
         pprint.pprint( expected )
     self.assertEquals( tested.saved, expected )
 def _testWithHeaders( self, headersContents, contents, expected ):
     tested = savingiterator.SavingIterator()
     with tools.temporaryFile( headersContents ) as headersContentsFile:
         fullContents = ( '#include "%s"\n' % headersContentsFile ) + contents
         with tools.temporaryFile( fullContents ) as contentsFile:
             tested.process( contentsFile )
     if tested.saved != expected:
         pprint.pprint( tested.saved )
         pprint.pprint( expected )
     self.assertEquals( tested.saved, expected )
Beispiel #3
0
 def _testWithHeaders( self, headersContents, contents, expected ):
     tested = savingiterator.SavingIterator()
     with tools.temporaryFile( headersContents ) as headersContentsFile:
         fullContents = ( '#include "%s"\n' % headersContentsFile ) + contents
         with tools.temporaryFile( fullContents ) as contentsFile:
             tested.process( contentsFile )
     if tested.saved != expected:
         pprint.pprint( tested.saved )
         pprint.pprint( expected )
     self.assertEquals( tested.saved, expected )
 def _simpleTest( self, contents, expected ):
     tested = savingiterator.SavingIterator()
     with tools.temporaryFile( contents ) as contentsFile:
         tested.process( contentsFile )
     if tested.saved != expected:
         pprint.pprint( tested.saved )
         pprint.pprint( expected )
     self.assertEquals( tested.saved, expected )
 def test_defines( self ):
     contents = "DEFINESTRUCT name_of_struct;"
     tested = savingiterator.SavingIterator()
     with tools.temporaryFile( contents ) as contentsFile:
         tested.process( contentsFile, defines = [ "DEFINESTRUCT=struct" ] )
     expected = [ dict( callbackName = "structForwardDeclaration", name = "name_of_struct" ) ]
     if tested.saved != expected:
         pprint.pprint( tested.saved )
         pprint.pprint( expected )
     self.assertEquals( tested.saved, expected )
 def _parseError( self, contents ):
     tested = savingiterator.SavingIterator()
     tested.printErrors = False
     with tools.temporaryFile( contents ) as contentsFile:
         try:
             tested.process( contentsFile )
         except:
             return
         else:
             raise Exception( "Expected parsing to fail" )