def testAddElements(self): try: silent_remove(ADD_ELEMENT_OUT) main(["-c", ADD_ELEMENT_INI]) self.assertFalse(diff_lines(ADD_ELEMENT_OUT, GOOD_ADD_ELEMENT_OUT)) finally: silent_remove(ADD_ELEMENT_OUT, disable=DISABLE_REMOVE)
def testEmreAddElements(self): # As above, but a larger/different PDB try: main(["-c", EMRE_ADD_ELEMENT_INI]) self.assertFalse(diff_lines(EMRE_ADD_ELEMENT_OUT, GOOD_EMRE_ADD_ELEMENT_OUT)) finally: silent_remove(EMRE_ADD_ELEMENT_OUT, disable=DISABLE_REMOVE)
def testHelp(self): test_input = ['-h'] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertFalse(output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
def testPrintQMMM(self): try: main(["-c", QMMM_OUT_INI]) self.assertFalse(diff_lines(QMMM_PDB_OUT, QMMM_PDB_IN)) self.assertFalse(diff_lines(QMMM_OUT, GOOD_QMMM_OUT)) self.assertFalse(diff_lines(VMD_ATOMS_OUT, GOOD_VMD_ATOMS_OUT)) finally: silent_remove(QMMM_PDB_OUT, disable=DISABLE_REMOVE) silent_remove(QMMM_OUT, disable=DISABLE_REMOVE) silent_remove(VMD_ATOMS_OUT, disable=DISABLE_REMOVE)
def testCheckWaterOrder(self): test_input = ["-c", CHECK_WATER_ORDER_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) try: with capture_stderr(main, test_input) as output: for message in WATER_OUT_OF_ORDER_MESSAGES: self.assertTrue(message in output) self.assertLess(len(output), 650) finally: silent_remove(DEF_OUT, disable=DISABLE_REMOVE)
def testAddElemReadDict(self): # There will be a missing element because of a missing key in the specified dictionary test_input = ["-c", READ_ELEM_DICT_INI] try: silent_remove(ADD_ELEMENT_OUT) if logger.isEnabledFor(logging.DEBUG): main(test_input) silent_remove(ADD_ELEMENT_OUT) with capture_stderr(main, test_input) as output: self.assertTrue("Please add atom type" in output) self.assertFalse(diff_lines(ADD_ELEMENT_OUT, GOOD_READ_ELEM_OUT)) finally: silent_remove(ADD_ELEMENT_OUT, disable=DISABLE_REMOVE)
def testAddElemReadDictNoOverwrite(self): # Make sure preserves the element from the original pdb even though not in the read dict test_input = ["-c", READ_ELEM_DICT_KEEP_ELEM_INI] try: silent_remove(DEF_OUT) if logger.isEnabledFor(logging.DEBUG): main(test_input) else: with capture_stderr(main, ["-c", READ_ELEM_DICT_KEEP_ELEM_INI]) as output: self.assertTrue("Please add atom type" in output) self.assertFalse(diff_lines(DEF_OUT, GOOD_ADD_ELEMENT_OUT)) finally: silent_remove(DEF_OUT, disable=DISABLE_REMOVE)
def testAddElementsMissingType(self): test_input = ["-c", ADD_ELEMENT_MISSING_TYPE_INI] try: if logger.isEnabledFor(logging.DEBUG): main(test_input) else: with capture_stderr(main, test_input) as output: # testing that only get the warning once, so check output length. May change wording a bit, # so checked than less than length + a buffer (which is less than if multiple warnings are printed) self.assertLess(len(output), 200) self.assertTrue("Please add atom type" in output) self.assertFalse(diff_lines(ADD_ELEMENT_MISSING_OUT, ADD_ELEMENT_MISSING_ORIG)) finally: silent_remove(ADD_ELEMENT_MISSING_OUT, disable=DISABLE_REMOVE)
def testChangeRenumMol(self): try: main(["-c", MOL_CHANGE_RENUM_INI]) self.assertFalse(diff_lines(DEF_OUT, GOOD_MOL_CHANGE_RENUM_OUT)) finally: silent_remove(DEF_OUT, disable=DISABLE_REMOVE)