示例#1
0
 def __testFileReaderExceptionHandler2(self, fp, enforceAscii=False):
     """Test case -  read selected categories from PDBx and handle exceptions
     """
     ok = True
     try:
         io = IoAdapter(raiseExceptions=True)
         containerList = io.readFile(fp,
                                     enforceAscii=enforceAscii,
                                     outDirPath=self.__pathOutputDir)
         self.assertGreaterEqual(len(containerList), 1)
         #
     except PdbxSyntaxError as e:
         logger.debug("Expected syntax failure %s", str(e))
         self.assertTrue(ok)
     except PdbxError as e:
         logger.debug("Expected character encoding failure %s", str(e))
         self.assertTrue(ok)
     except Exception as e:
         logger.error("Unexpected exception %s", type(e).__name__)
         self.fail("Unexpected exception raised: " + str(e))
     else:
         self.fail("Expected exception not raised")
示例#2
0
    def __testReaders(self, fPath):
        """Tests python and IoAdapter readers and checks values"""
        # Python reader

        myContainerList = []
        with open(fPath, "r") as ifh:
            pRd = PdbxReader(ifh)
            pRd.read(myContainerList)

        self.__testValues(myContainerList)

        # C++ IoAdapter reader
        try:
            io = IoAdapter(raiseExceptions=True)
            containerList = io.readFile(fPath, outDirPath=self.__pathOutputDir)
            logger.debug("Read %d data blocks", len(containerList))
            self.assertEqual(len(containerList), 1)
        except Exception as e:
            logger.error("Failing with %s", str(e))
            self.fail()

        self.__testValues(containerList)