def _simpleTest(self, contents, expected): tested = savingiterator.SavingIterator() contentsFile = self._tempfile(contents) tested.process(contentsFile.name, includes=[self._gccCPPIncludeDir()]) 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 _testInclude(self, contents1, contents2, expected): tested = savingiterator.SavingIterator() contentsFile1 = self._tempfile(contents1) contentsFile2 = self._tempfile('#include "%s"\n%s' % (contentsFile1.name, contents2)) tested.process(contentsFile2.name) 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 contentsFile = self._tempfile(contents) try: tested.process(contentsFile.name) except: return else: raise Exception("Expected parsing to fail")
def _simpleTest(self, contents, expected): tested = savingiterator.SavingIterator() contentsFile = self._tempfile(contents) tested.process(contentsFile.name) if tested.saved != expected: pprint.pprint(tested.saved) pprint.pprint(expected) self.assertEquals(tested.saved, expected) if platform.system() == "Windows": os.remove(contentsFile.name)
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 _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 _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" )
def _testWithHeaders(self, headersContents, contents, expected): tested = savingiterator.SavingIterator() headersContentsFile = self._tempfile(headersContents) contentsFile = self._tempfile(('#include "%s"\n' % headersContentsFile.name) + contents) tested.process(contentsFile.name, includes=[self._gccCPPIncludeDir()]) 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 )