def testUpdateChemicalCompositionWithNativeSulfurAtom(self): """ """ from XSDataCommon import XSDataAngle from XSDataCommon import XSDataString from XSDataCommon import XSDataInteger from XSDataCommon import XSDataString from XSDataCommon import XSDataFloat from XSDataMXv1 import XSDataStructure from XSDataMXv1 import XSDataChain from XSDataMXv1 import XSDataAtom from XSDataMXv1 import XSDataLigand from XSDataMXv1 import XSDataSampleCrystalMM from XSDataMXv1 import XSDataChemicalCompositionMM from XSDataMXv1 import XSDataAtomicComposition from XSDataMXv1 import XSDataSolvent from XSDataMXv1 import XSDataCell from XSDataMXv1 import XSDataSpaceGroup edPluginStrategy = self.createPlugin() xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml")) edPluginStrategy.setConfiguration(xsPluginItemGood01) edPluginStrategy.configure() xsDataSampleCrystalMM = XSDataSampleCrystalMM() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataFloat(2)) xsDataChain.setNumberOfMonomers(XSDataFloat(60)) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) EDAssert.equal(3, updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue()) EDAssert.equal("S", updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue()) xsDataSampleCrystalMM = XSDataSampleCrystalMM() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataFloat(2)) xsDataChain.setNumberOfMonomers(XSDataFloat(60)) xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataFloat(4)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom() for heavyAtom in heavyAtoms: EDVerbose.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue())) if(heavyAtom.getSymbol().getValue() == "S"): EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
def testGenerateStrategyShortSummary(self): edPluginStrategy = self.createPlugin() strReferenceOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataResultStrategy_2_sweep.xml") strXML = self.readAndParseFile(strReferenceOutputFile) xsDataStrategyResult = XSDataResultStrategy.parseString(strXML) edPluginStrategy.generateStrategyShortSummary(xsDataStrategyResult) for strLine in edPluginStrategy.getDataOutput("strategyShortSummary")[0].getValue().split("\n"): EDVerbose.unitTest(strLine)
def testGenerateStrategyShortSummary(self): edPluginStrategy = self.createPlugin() strReferenceOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataResultStrategy_2_sweep.xml") strXML = self.readAndParseFile(strReferenceOutputFile) xsDataStrategyResult = XSDataResultStrategy.parseString(strXML) edPluginStrategy.generateStrategyShortSummary(xsDataStrategyResult) for strLine in edPluginStrategy.getDataOutput("strategyShortSummary")[0].getValue().split("\n"): EDVerbose.unitTest(strLine)
def testGenerateIntegrationShortSummary(self): edPluginControlIntegrationv10 = self.createPlugin() strReferenceOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataIntegrationResult_reference.xml") strXML = self.readAndParseFile(strReferenceOutputFile) xsDataIntegrationResult = XSDataIntegrationResult.parseString(strXML) edPluginControlIntegrationv10.generateIntegrationShortSummary(xsDataIntegrationResult) for strLine in edPluginControlIntegrationv10.getDataOutput("integrationShortSummary")[0].getValue().split("\n"): EDVerbose.unitTest(strLine)
def postProcess(self): # try to remove any created directories in /tmp listFilesTmp = os.listdir("/tmp") for strFile in listFilesTmp: if strFile.startswith("EDNA2html.log"): try: os.remove(os.path.join("/tmp", strFile)) except: EDVerbose.unitTest("Couldn't delete temporary file: %s" % strFile)
def postProcess(self): # try to remove any created directories in /tmp listFilesTmp = os.listdir("/tmp") for strFile in listFilesTmp: if strFile.startswith("EDNA2html.log"): try: os.remove(os.path.join("/tmp", strFile)) except: EDVerbose.unitTest("Couldn't delete temporary file: %s" % strFile)
def testUpdateChemicalCompositionWithNativeSulfurAtom(self): from XSDataCommon import XSDataAngle from XSDataCommon import XSDataString from XSDataCommon import XSDataInteger from XSDataCommon import XSDataString from XSDataCommon import XSDataFloat from XSDataMXv1 import XSDataStructure from XSDataMXv1 import XSDataChain from XSDataMXv1 import XSDataAtom from XSDataMXv1 import XSDataLigand from XSDataMXv1 import XSDataSampleCrystalMM from XSDataMXv1 import XSDataChemicalCompositionMM from XSDataMXv1 import XSDataAtomicComposition from XSDataMXv1 import XSDataSolvent from XSDataMXv1 import XSDataCell from XSDataMXv1 import XSDataSpaceGroup edPluginStrategy = self.createPlugin() xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml")) edPluginStrategy.setConfiguration(xsPluginItemGood01) edPluginStrategy.configure() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataFloat(2)) xsDataChain.setNumberOfMonomers(XSDataFloat(60)) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) EDAssert.equal(3, updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue()) EDAssert.equal("S", updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue()) xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataFloat(2)) xsDataChain.setNumberOfMonomers(XSDataFloat(60)) xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataFloat(4)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom() for heavyAtom in heavyAtoms: EDVerbose.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue())) if(heavyAtom.getSymbol().getValue() == "S"): EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
def unitTestDetectNumberOfCPUs(self): """ test the execution of detectNumberOfCPUs """ iNbCPU = EDUtilsParallel.detectNumberOfCPUs() EDVerbose.unitTest("Detection of the number of Cores: %s" % iNbCPU) EDAssert.equal(types.IntType, type(iNbCPU), "Number of CPU is an integer") iNbCPU = EDUtilsParallel.detectNumberOfCPUs(1) #limited to 1 EDAssert.equal(1, iNbCPU, "Limit number of CPU") iNbCPU = EDUtilsParallel.detectNumberOfCPUs(100, True) #forced to 100 EDAssert.equal(100, iNbCPU, "Force number of CPU")
def unitTestDetectNumberOfCPUs(self): """ test the execution of detectNumberOfCPUs """ iNbCPU = EDUtilsParallel.detectNumberOfCPUs() EDVerbose.unitTest("Detection of the number of Cores: %s" % iNbCPU) EDAssert.equal(types.IntType, type(iNbCPU), "Number of CPU is an integer") iNbCPU = EDUtilsParallel.detectNumberOfCPUs(1) #limited to 1 EDAssert.equal(1, iNbCPU, "Limit number of CPU") iNbCPU = EDUtilsParallel.detectNumberOfCPUs(100, True) #forced to 100 EDAssert.equal(100, iNbCPU, "Force number of CPU")
def loadTestImage(self, _listImageFileName): """ This method checks the presence of all the images in the list of image file names in the $EDNA_HOME/tests/data/images directory. If one image is not present this method tries to download it from http://www.edna-site.org/data/tests/images """ if not os.path.isdir(EDUtilsPath.EDNA_TESTIMAGES): os.makedirs(EDUtilsPath.EDNA_TESTIMAGES) for strImageName in _listImageFileName: strImagePath = os.path.join(EDUtilsPath.EDNA_TESTIMAGES, strImageName) if (not os.path.exists(strImagePath)): EDVerbose.unitTest( "Trying to download image %s, timeout set to %d s" % (strImagePath, iMAX_DOWNLOAD_TIME)) if "http_proxy" in os.environ: dictProxies = {'http': os.environ["http_proxy"]} proxy_handler = urllib2.ProxyHandler(dictProxies) opener = urllib2.build_opener(proxy_handler).open else: opener = urllib2.urlopen # Nota: since python2.6 there is a timeout in the urllib2 timer = threading.Timer(iMAX_DOWNLOAD_TIME + 1, timeoutDuringDownload) timer.start() if sys.version > (2, 6): data = opener("%s/%s" % (self.URL_EDNA_SITE, strImageName), data=None, timeout=iMAX_DOWNLOAD_TIME).read() else: data = opener("%s/%s" % (self.URL_EDNA_SITE, strImageName), data=None).read() timer.cancel() try: open(strImagePath, "wb").write(data) except IOError: raise IOError( "unable to write downloaded data to disk at %s" % strImagePath) if os.path.exists(strImagePath): EDVerbose.unitTest("Image %s successfully downloaded." % strImagePath) else: raise RuntimeError( "Could not automatically download test images %r! \n \ If you are behind a firewall, please set the environment variable http_proxy. \n \ Otherwise please try to download the images manually from \n \ http://www.edna-site.org/data/tests/images" % _listImageFileName)
def run(self): """ Executes the plugin and checks that the data output is not None """ EDVerbose.DEBUG("EDTestCasePluginExecute: Executing " + self.getPluginName()) self._edPlugin.executeSynchronous() # Check that the plugin didn't end in failure EDAssert.equal(self._bAcceptPluginFailure , self._edPlugin.isFailure(), \ "Plugin failure assert: should be %r, was %r" % (self._bAcceptPluginFailure , self._edPlugin.isFailure())) # Checks the number of error messages EDAssert.equal(self._iNoExpectedErrorMessages, len(self._edPlugin.getListOfErrorMessages()), \ "Number of error messages: expected %d, got %d" % (self._iNoExpectedErrorMessages, len(self._edPlugin.getListOfErrorMessages()))) # Checks the number of warning messages EDAssert.equal(self._iNoExpectedWarningMessages, len(self._edPlugin.getListOfWarningMessages()), \ "Number of warning messages: expected %d, got %d" % (self._iNoExpectedWarningMessages, len(self._edPlugin.getListOfWarningMessages()))) # Check the output data listOfDataOutputKeys = self._edPlugin.getListOfDataOutputKeys() for strReferenceOutputDataKey in self._dictStrReferenceDataOutputFiles.keys(): # Only check the reference data keys if (strReferenceOutputDataKey in listOfDataOutputKeys): EDVerbose.unitTest("Testing data output for %s" % strReferenceOutputDataKey) listReferenceFile = self._dictStrReferenceDataOutputFiles[ strReferenceOutputDataKey ] if (type(listReferenceFile) != types.ListType): listReferenceFile = [ listReferenceFile ] listReferenceOutput = [] for strReferenceFile in listReferenceFile: listReferenceOutput.append(self.readAndParseFile(strReferenceFile)) # Obtained output listObtainedOutputXML = [] pyObjectObtainedDataOutput = self._edPlugin.getDataOutput(strReferenceOutputDataKey) listObtainedOutput = None if (type(pyObjectObtainedDataOutput) == types.ListType): listObtainedOutput = pyObjectObtainedDataOutput else: listObtainedOutput = [ pyObjectObtainedDataOutput ] for xsDataOutput in listObtainedOutput: listObtainedOutputXML.append(xsDataOutput.marshal()) # Compare the lists, sort them first listReferenceOutput.sort() listObtainedOutputXML.sort() for iIndex in range(len(listReferenceOutput)): # Check of deprecated tests - if default data key only warn if (strReferenceOutputDataKey == self._strDefaultOutputDataKey): if (listReferenceOutput[ iIndex ] != listObtainedOutputXML[ iIndex ]): EDVerbose.unitTest("WARNING! Expected output is not corresponding to obtained output.") else: EDAssert.equal(listReferenceOutput[ iIndex ], listObtainedOutputXML[ iIndex ]) # Legacy - save output data if (strReferenceOutputDataKey == self._strDefaultOutputDataKey): if (self.m_edObtainedOutputDataFile is None): self.m_edObtainedOutputDataFile = self.getPluginName() + "_output.xml" EDUtilsFile.writeFile(self.m_edObtainedOutputDataFile, self._edPlugin.getDataOutput().marshal())
def testUpdateChemicalCompositionWithNativeSulfurAtom(self): edPluginStrategy = self.createPlugin() xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml")) edPluginStrategy.setConfiguration(xsPluginItemGood01) edPluginStrategy.configure() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataChain.setNumberOfMonomers(XSDataDouble(60)) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) EDAssert.equal( 3, updatedChemicalComposition.getStructure() .getChain()[0] .getHeavyAtoms() .getAtom()[0] .getNumberOf() .getValue(), ) EDAssert.equal( "S", updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue(), ) xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataChain.setNumberOfMonomers(XSDataDouble(60)) xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataDouble(4)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom() for heavyAtom in heavyAtoms: EDVerbose.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue())) if heavyAtom.getSymbol().getValue() == "S": EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
def testExecute(self): self.run() # Checks that there are no error messages edPlugin = self.getPlugin() # Checks some parts of the result xsDataIntegrationResultObtained = edPlugin.getDataOutput() # Check that we have at least the best files in each integration subwedge for xsDataIntegrationSubWedgeResult in xsDataIntegrationResultObtained.getIntegrationSubWedgeResult(): if ((xsDataIntegrationSubWedgeResult.getBestfileDat() is None) or \ (xsDataIntegrationSubWedgeResult.getBestfilePar() is None) or \ (xsDataIntegrationSubWedgeResult.getBestfileHKL() is None)): EDVerbose.unitTest("Missing BEST output data in the integration subwedge results!") EDAssert.equal(True, False)
def testExecute(self): self.run() # Checks that there are no error messages edPlugin = self.getPlugin() # Checks some parts of the result xsDataIntegrationResultObtained = edPlugin.getDataOutput() # Check that we have at least the best files in each integration subwedge for xsDataIntegrationSubWedgeResult in xsDataIntegrationResultObtained.getIntegrationSubWedgeResult( ): if ((xsDataIntegrationSubWedgeResult.getBestfileDat() is None) or \ (xsDataIntegrationSubWedgeResult.getBestfilePar() is None) or \ (xsDataIntegrationSubWedgeResult.getBestfileHKL() is None)): EDVerbose.unitTest( "Missing BEST output data in the integration subwedge results!" ) EDAssert.equal(True, False)
def processKernel(self): """ This method executes the test suite. """ EDVerbose.DEBUG("Execution: EDTestSuite.processKernel()") EDVerbose.screen("") EDVerbose.screen("") EDVerbose.unitTest("###################################################################") EDVerbose.unitTest("STARTING::" + self.getTestName()) EDVerbose.unitTest("###################################################################") self.setTimeInit() for edTestCase in self.__listTestCase: edTestCase.execute() if edTestCase.isExecuted(): self.__iNumberTestMethodSuccess += edTestCase.getNumberTestMethodSuccess() if edTestCase.getNumberTestMethodFailure() == 0: self.__iNumberTestCaseSuccess += 1 else: self.__iNumberTestCaseFailure += 1 self.__iNumberTestMethodFailure += edTestCase.getNumberTestMethodFailure() self.__dictTestCaseFailureMessages[edTestCase.getClassName()] = edTestCase.getMethodFailureMessages() else: self.__dictTestCaseNotExecuted[edTestCase.getClassName()] = edTestCase.getReasonForNotBeingExectuted() EDVerbose.screen() for edTestSuite in self.__listTestSuite: edTestSuite.execute() self.__iNumberTestSuite += 1 self.__iNumberTestMethodSuccess += edTestSuite.getNumberTestMethodSuccess() self.__iNumberTestMethodFailure += edTestSuite.getNumberTestMethodFailure() self.__iNumberTestCaseSuccess += edTestSuite.getNumberTestCaseSuccess() self.__iNumberTestCaseFailure += edTestSuite.getNumberTestCaseFailure() self.extendDictionary(self.__dictTestCaseNotExecuted, edTestSuite.getDictTestCaseNotExecuted()) self.extendDictionary(self.__dictTestSuiteNotExecuted, edTestSuite.getDictTestSuiteNotExecuted()) self.extendDictionary(self.__dictTestCaseFailureMessages, edTestSuite.getDictTestCaseFailureMessages()) self.setTimeEnd()
def loadTestImage(self, _listImageFileName): """ This method checks the presence of all the images in the list of image file names in the $EDNA_HOME/tests/data/images directory. If one image is not present this method tries to download it from http://www.edna-site.org/data/tests/images """ if not os.path.isdir(EDUtilsPath.EDNA_TESTIMAGES): os.makedirs(EDUtilsPath.EDNA_TESTIMAGES) for strImageName in _listImageFileName: strImagePath = os.path.join(EDUtilsPath.EDNA_TESTIMAGES, strImageName) if(not os.path.exists(strImagePath)): EDVerbose.unitTest("Trying to download image %s, timeout set to %d s" % (strImagePath, iMAX_DOWNLOAD_TIME)) if os.environ.has_key("http_proxy"): dictProxies = {'http': os.environ["http_proxy"]} proxy_handler = urllib2.ProxyHandler(dictProxies) opener = urllib2.build_opener(proxy_handler).open else: opener = urllib2.urlopen # Nota: since python2.6 there is a timeout in the urllib2 timer = threading.Timer(iMAX_DOWNLOAD_TIME + 1, timeoutDuringDownload) timer.start() if sys.version > (2, 6): data = opener("%s/%s" % (self.URL_EDNA_SITE, strImageName), data=None, timeout=iMAX_DOWNLOAD_TIME).read() else: data = opener("%s/%s" % (self.URL_EDNA_SITE, strImageName), data=None).read() timer.cancel() try: open(strImagePath, "wb").write(data) except IOError: raise IOError, "unable to write downloaded data to disk at %s" % strImagePath if os.path.exists(strImagePath): EDVerbose.unitTest("Image %s successfully downloaded." % strImagePath) else: raise RuntimeError, "Could not automatically download test images %r! \n \ If you are behind a firewall, please set the environment variable http_proxy. \n \ Otherwise please try to download the images manually from \n \ http://www.edna-site.org/data/tests/images" % _listImageFileName
def testUpdateChemicalCompositionWithNativeSulfurAtom(self): edPluginStrategy = self.createPlugin() xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration_ESRF.xml")) edPluginStrategy.setConfiguration(xsPluginItemGood01) edPluginStrategy.configure() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataChain.setNumberOfMonomers(XSDataDouble(60)) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) EDAssert.equal(3, updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue()) EDAssert.equal("S", updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom()[0].getSymbol().getValue()) xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataChain.setNumberOfMonomers(XSDataDouble(60)) xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataDouble(4)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition(xsDataComposition) heavyAtoms = updatedChemicalComposition.getStructure().getChain()[0].getHeavyAtoms().getAtom() for heavyAtom in heavyAtoms: EDVerbose.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue())) if(heavyAtom.getSymbol().getValue() == "S"): EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
def processKernel(self): """ This method executes the test suite. """ EDVerbose.DEBUG("Execution: EDTestSuite.processKernel()") EDVerbose.screen("") EDVerbose.screen("") EDVerbose.unitTest( "###################################################################" ) EDVerbose.unitTest("STARTING::" + self.getTestName()) EDVerbose.unitTest( "###################################################################" ) self.setTimeInit() for edTestCase in self.__listTestCase: if edTestCase._deactivated: continue edTestCase.execute() if edTestCase._deactivated: continue if edTestCase.isExecuted(): self.__iNumberTestMethodSuccess += edTestCase.getNumberTestMethodSuccess( ) if edTestCase.getNumberTestMethodFailure() == 0: self.__iNumberTestCaseSuccess += 1 else: self.__iNumberTestCaseFailure += 1 self.__iNumberTestMethodFailure += edTestCase.getNumberTestMethodFailure( ) self.__dictTestCaseFailureMessages[edTestCase.getClassName( )] = edTestCase.getMethodFailureMessages() else: self.__dictTestCaseNotExecuted[edTestCase.getClassName( )] = edTestCase.getReasonForNotBeingExectuted() EDVerbose.screen() for edTestSuite in self.__listTestSuite: edTestSuite.execute() self.__iNumberTestSuite += 1 self.__iNumberTestMethodSuccess += edTestSuite.getNumberTestMethodSuccess( ) self.__iNumberTestMethodFailure += edTestSuite.getNumberTestMethodFailure( ) self.__iNumberTestCaseSuccess += edTestSuite.getNumberTestCaseSuccess( ) self.__iNumberTestCaseFailure += edTestSuite.getNumberTestCaseFailure( ) self.extendDictionary(self.__dictTestCaseNotExecuted, edTestSuite.getDictTestCaseNotExecuted()) self.extendDictionary(self.__dictTestSuiteNotExecuted, edTestSuite.getDictTestSuiteNotExecuted()) self.extendDictionary(self.__dictTestCaseFailureMessages, edTestSuite.getDictTestCaseFailureMessages()) self.setTimeEnd()
def postProcess(self): """ This method writes out the results of the test suite. """ EDVerbose.screen() EDVerbose.screen() EDVerbose.unitTest( "###################################################################" ) strResult = None if self.__iNumberTestCaseFailure == 0 and self.__iNumberTestMethodFailure == 0: strResult = "SUCCESS" else: strResult = "FAILURE" EDVerbose.unitTest("Result for %s : %s" % (self.getTestName(), strResult)) EDVerbose.unitTest() if self.__iNumberTestSuite > 0: EDVerbose.unitTest( " Number of executed test suites in this test suite : %d" % self.__iNumberTestSuite) EDVerbose.unitTest() if self.__dictTestSuiteNotExecuted != {}: EDVerbose.unitTest() EDVerbose.unitTest( "OBS! The following test suites were not executed due to errors:" ) EDVerbose.unitTest() for strTestSuiteName in self.__dictTestSuiteNotExecuted.keys(): EDVerbose.unitTest( " %s : %s" % (self.__dictTestSuiteNotExecuted[strTestSuiteName], strTestSuiteName)) EDVerbose.unitTest() if self.__dictTestCaseNotExecuted != {}: EDVerbose.unitTest() EDVerbose.unitTest( "OBS! The following test cases not executed due to errors:") EDVerbose.unitTest() for strTestCaseName in self.__dictTestCaseNotExecuted.keys(): EDVerbose.unitTest(" %s :" % strTestCaseName) EDVerbose.unitTest( " %s" % self.__dictTestCaseNotExecuted[strTestCaseName]) EDVerbose.unitTest() EDVerbose.unitTest( " Total number of test cases NOT EXECUTED : %d" % len(self.__dictTestCaseNotExecuted)) EDVerbose.unitTest() if self.__iNumberTestCaseSuccess != 0 or self.__iNumberTestCaseFailure != 0: EDVerbose.unitTest( " Total number of test cases executed with SUCCESS : %d" % self.__iNumberTestCaseSuccess) EDVerbose.unitTest( " Total number of test cases executed with FAILURE : %d" % self.__iNumberTestCaseFailure) EDVerbose.unitTest() if self.__dictTestCaseFailureMessages != {}: EDVerbose.unitTest("") EDVerbose.unitTest( "OBS! The following test methods ended with failure:") EDVerbose.unitTest("") for strTestCaseName in self.__dictTestCaseFailureMessages.keys(): EDVerbose.unitTest(" %s :" % strTestCaseName) for strMethodName in self.__dictTestCaseFailureMessages[ strTestCaseName].keys(): EDVerbose.unitTest(" %s :" % strMethodName.split(".")[1]) EDVerbose.unitTest( " %s" % self.__dictTestCaseFailureMessages[strTestCaseName] [strMethodName]) EDVerbose.unitTest("") EDVerbose.unitTest("") if self.__iNumberTestMethodSuccess != 0 or self.__iNumberTestMethodFailure != 0: EDVerbose.unitTest( "Total number of test methods executed with SUCCESS : %d" % self.__iNumberTestMethodSuccess) EDVerbose.unitTest( "Total number of test methods executed with FAILURE : %d" % self.__iNumberTestMethodFailure) EDVerbose.unitTest() EDVerbose.unitTest( " Runtime : %.3f [s]" % self.getRunTime()) EDVerbose.unitTest( "###################################################################" )
def processKernel(self): """ Executes the test case. """ EDVerbose.DEBUG("EDTestCase.processKernel") EDVerbose.screen() EDVerbose.unitTest( "===================================================================" ) if self.getTestSuiteName() is not None: EDVerbose.unitTest("TEST SUITE : %s" % self.getTestSuiteName()) EDVerbose.unitTest("TEST CASE : %s" % self.getClassName()) EDVerbose.unitTest(" ") if self.__strReasonForNotBeingExecuted == "": self.setTimeInit() iNumberMethods = self.getNumberOfTests() EDVerbose.unitTest("Total number of tests : %d" % iNumberMethods) EDVerbose.unitTest() iTestCaseNumber = 0 if self.getListTest() == []: self.__strReasonForNotBeingExecuted = "No test methods!" else: for pyTestMethod in self.getListTest(): iTestCaseNumber = iTestCaseNumber + 1 strMethodName = EDUtilsTest.patchMethodName(pyTestMethod) EDVerbose.unitTest( "-------------------------------------------------------------------" ) EDVerbose.unitTest("Test case method : %s" % strMethodName) EDVerbose.unitTest() try: pyTestMethod() self.__iNumberTestMethodSuccess += 1 EDVerbose.unitTest("%s executed with SUCCESS" % strMethodName) EDVerbose.unitTest() except AssertionError as pyException: self.__dictMethodFailureMessages[strMethodName] = str( pyException) self.__iNumberTestMethodFailure += 1 EDVerbose.unitTest("Assertion Error Raised!") EDVerbose.unitTest("%s executed with FAILURE" % strMethodName) EDVerbose.unitTest() except Exception as pyException: self.__dictMethodFailureMessages[strMethodName] = str( pyException) self.__iNumberTestMethodFailure += 1 EDVerbose.unitTest("Unexpected Error!") EDVerbose.unitTest("%s executed with FAILURE" % strMethodName) EDVerbose.unitTest() EDVerbose.writeErrorTrace() EDVerbose.unitTest() self.__bIsExecuted = True self.setTimeEnd()
def postProcess(self): """ Writes out a summary of the test case. """ if self.__bIsExecuted: EDVerbose.unitTest( "-------------------------------------------------------------------" ) EDVerbose.unitTest("Result for %s" % self.getClassName()) EDVerbose.unitTest() EDVerbose.unitTest("Total number of test methods : %d" % self.getNumberOfTests()) EDVerbose.unitTest("Number of SUCCESS : %d" % self.__iNumberTestMethodSuccess) EDVerbose.unitTest("Number of FAILURE : %d" % self.__iNumberTestMethodFailure) if self.__dictMethodFailureMessages != {}: EDVerbose.unitTest("") EDVerbose.unitTest("List of test methods ending with failure:") for strMethodName in self.__dictMethodFailureMessages: EDVerbose.unitTest(" %s :" % strMethodName.split(".")[1]) EDVerbose.unitTest( " %s" % self.__dictMethodFailureMessages[strMethodName]) EDVerbose.unitTest() EDVerbose.unitTest("Runtime : %.3f [s]" % self.getRunTime()) EDVerbose.unitTest( "===================================================================" ) else: EDVerbose.unitTest() EDVerbose.unitTest("Test case %s not executed :" % self.getClassName()) EDVerbose.unitTest(self.__strReasonForNotBeingExecuted) EDVerbose.unitTest() EDVerbose.unitTest( "===================================================================" )
def postProcess(self): """ Writes out a summary of the test case. """ if self.__bIsExecuted: EDVerbose.unitTest("-------------------------------------------------------------------") EDVerbose.unitTest("Result for %s" % self.getClassName()) EDVerbose.unitTest() EDVerbose.unitTest("Total number of test methods : %d" % self.getNumberOfTests()) EDVerbose.unitTest("Number of SUCCESS : %d" % self.__iNumberTestMethodSuccess) EDVerbose.unitTest("Number of FAILURE : %d" % self.__iNumberTestMethodFailure) if self.__dictMethodFailureMessages != {}: EDVerbose.unitTest("") EDVerbose.unitTest("List of test methods ending with failure:") for strMethodName in self.__dictMethodFailureMessages: EDVerbose.unitTest(" %s :" % strMethodName.split(".")[1]) EDVerbose.unitTest(" %s" % self.__dictMethodFailureMessages[strMethodName]) EDVerbose.unitTest() EDVerbose.unitTest("Runtime : %.3f [s]" % self.getRunTime()) EDVerbose.unitTest("===================================================================") else: EDVerbose.unitTest() EDVerbose.unitTest("Test case %s not executed :" % self.getClassName()) EDVerbose.unitTest(self.__strReasonForNotBeingExecuted) EDVerbose.unitTest() EDVerbose.unitTest("===================================================================")
def processKernel(self): """ Executes the test case. """ EDVerbose.DEBUG("EDTestCase.processKernel") EDVerbose.screen() EDVerbose.unitTest("===================================================================") if self.getTestSuiteName() is not None: EDVerbose.unitTest("TEST SUITE : %s" % self.getTestSuiteName()) EDVerbose.unitTest("TEST CASE : %s" % self.getClassName()) EDVerbose.unitTest(" ") if self.__strReasonForNotBeingExecuted == "": self.setTimeInit() iNumberMethods = self.getNumberOfTests() EDVerbose.unitTest("Total number of tests : %d" % iNumberMethods) EDVerbose.unitTest() iTestCaseNumber = 0 if self.getListTest() == []: self.__strReasonForNotBeingExecuted = "No test methods!" else: for pyTestMethod in self.getListTest(): iTestCaseNumber = iTestCaseNumber + 1 strMethodName = EDUtilsTest.patchMethodName(pyTestMethod) EDVerbose.unitTest("-------------------------------------------------------------------") EDVerbose.unitTest("Test case method : %s" % strMethodName) EDVerbose.unitTest() try: pyTestMethod() self.__iNumberTestMethodSuccess += 1 EDVerbose.unitTest("%s executed with SUCCESS" % strMethodName) EDVerbose.unitTest() except AssertionError, pyException: self.__dictMethodFailureMessages[strMethodName] = str(pyException) self.__iNumberTestMethodFailure += 1 EDVerbose.unitTest("Assertion Error Raised!") EDVerbose.unitTest("%s executed with FAILURE" % strMethodName) EDVerbose.unitTest() except Exception, pyException: self.__dictMethodFailureMessages[strMethodName] = str(pyException) self.__iNumberTestMethodFailure += 1 EDVerbose.unitTest("Unexpected Error!") EDVerbose.unitTest("%s executed with FAILURE" % strMethodName) EDVerbose.unitTest() EDVerbose.writeErrorTrace() EDVerbose.unitTest() self.__bIsExecuted = True self.setTimeEnd()
def postProcess(self): """ This method writes out the results of the test suite. """ EDVerbose.screen() EDVerbose.screen() EDVerbose.unitTest("###################################################################") strResult = None if self.__iNumberTestCaseFailure == 0 and self.__iNumberTestMethodFailure == 0: strResult = "SUCCESS" else: strResult = "FAILURE" EDVerbose.unitTest("Result for %s : %s" % (self.getTestName(), strResult)) EDVerbose.unitTest() if self.__iNumberTestSuite > 0: EDVerbose.unitTest(" Number of executed test suites in this test suite : %d" % self.__iNumberTestSuite) EDVerbose.unitTest() if self.__dictTestSuiteNotExecuted != {}: EDVerbose.unitTest() EDVerbose.unitTest("OBS! The following test suites were not executed due to errors:") EDVerbose.unitTest() for strTestSuiteName in self.__dictTestSuiteNotExecuted.keys(): EDVerbose.unitTest(" %s : %s" % (self.__dictTestSuiteNotExecuted[strTestSuiteName], strTestSuiteName)) EDVerbose.unitTest() if self.__dictTestCaseNotExecuted != {}: EDVerbose.unitTest() EDVerbose.unitTest("OBS! The following test cases not executed due to errors:") EDVerbose.unitTest() for strTestCaseName in self.__dictTestCaseNotExecuted.keys(): EDVerbose.unitTest(" %s :" % strTestCaseName) EDVerbose.unitTest(" %s" % self.__dictTestCaseNotExecuted[strTestCaseName]) EDVerbose.unitTest() EDVerbose.unitTest(" Total number of test cases NOT EXECUTED : %d" % len(self.__dictTestCaseNotExecuted)) EDVerbose.unitTest() if self.__iNumberTestCaseSuccess != 0 or self.__iNumberTestCaseFailure != 0: EDVerbose.unitTest(" Total number of test cases executed with SUCCESS : %d" % self.__iNumberTestCaseSuccess) EDVerbose.unitTest(" Total number of test cases executed with FAILURE : %d" % self.__iNumberTestCaseFailure) EDVerbose.unitTest() if self.__dictTestCaseFailureMessages != {}: EDVerbose.unitTest("") EDVerbose.unitTest("OBS! The following test methods ended with failure:") EDVerbose.unitTest("") for strTestCaseName in self.__dictTestCaseFailureMessages.keys(): EDVerbose.unitTest(" %s :" % strTestCaseName) for strMethodName in self.__dictTestCaseFailureMessages[strTestCaseName].keys(): EDVerbose.unitTest(" %s :" % strMethodName.split(".")[1]) EDVerbose.unitTest(" %s" % self.__dictTestCaseFailureMessages[strTestCaseName][strMethodName]) EDVerbose.unitTest("") EDVerbose.unitTest("") if self.__iNumberTestMethodSuccess != 0 or self.__iNumberTestMethodFailure != 0: EDVerbose.unitTest("Total number of test methods executed with SUCCESS : %d" % self.__iNumberTestMethodSuccess) EDVerbose.unitTest("Total number of test methods executed with FAILURE : %d" % self.__iNumberTestMethodFailure) EDVerbose.unitTest() EDVerbose.unitTest(" Runtime : %.3f [s]" % self.getRunTime()) EDVerbose.unitTest("###################################################################")