示例#1
0
 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 testMakeEqPar(self):
     try:
         for o_file in MULTI_OUT_FILES:
             silent_remove(o_file)
         main(["-c", PAR_EQ_INI])
         self.assertFalse(diff_lines(MULTI_PAR_OUT1, GOOD_MULTI_PAR_OUT1))
         self.assertFalse(diff_lines(MULTI_PAR_OUT2, GOOD_PAR_OUT))
         self.assertFalse(diff_lines(MULTI_PAR_OUT3, GOOD_MULTI_PAR_OUT3))
     finally:
         for o_file in MULTI_OUT_FILES:
             silent_remove(o_file, disable=DISABLE_REMOVE)
 def testMakeOneMultiPar(self):
     # Now, one parameter has multiple values
     try:
         for o_file in MULTI_OUT_FILES:
             silent_remove(o_file)
         main(["-c", PAR_ONE_MULTI_INI])
         self.assertFalse(diff_lines(MULTI_PAR_OUT1, GOOD_MULTI_PAR_OUT1))
         self.assertFalse(diff_lines(MULTI_PAR_OUT2, GOOD_PAR_OUT))
         self.assertFalse(diff_lines(MULTI_PAR_OUT3, GOOD_MULTI_PAR_OUT3))
     finally:
         for o_file in MULTI_OUT_FILES:
             silent_remove(o_file, disable=DISABLE_REMOVE)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 def testReorderAtoms(self):
     try:
         with capture_stdout(main, ["-c", DEF_INI]) as output:
             for message in WATER_OUT_OF_ORDER_MESSAGES:
                 self.assertFalse(message in output)
         self.assertFalse(diff_lines(DEF_OUT, GOOD_OUT))
     finally:
         silent_remove(DEF_OUT)
 def testMakeParCommandLine(self):
     # as in testMakePar, but specifying the created file name from the command line
     try:
         silent_remove(PAR_OUT)
         main(["-c", PAR_NO_NEW_FILE_NAME_INI, "-f", PAR_FNAME])
         self.assertFalse(diff_lines(PAR_OUT, GOOD_PAR_OUT))
     finally:
         silent_remove(PAR_OUT, disable=DISABLE_REMOVE)
 def testHist(self):
     try:
         main(["-f", HIST_INPUT, "-n", "-d", ",", "-s"])
         for p_file in [HIST_PNG1, HIST_PNG2, HIST_PNG3]:
             self.assertGreater(os.path.getsize(p_file), 10000)
         self.assertFalse(diff_lines(HIST_OUT, GOOD_HIST_OUT))
         self.assertFalse(diff_lines(HIST_COUNT, GOOD_HIST_COUNT))
     finally:
         [
             silent_remove(o_file, disable=DISABLE_REMOVE) for o_file in [
                 HIST_PNG1,
                 HIST_PNG2,
                 HIST_PNG3,
                 HIST_OUT,
                 HIST_COUNT,
             ]
         ]
示例#9
0
 def testCapitalGood(self):
     copyfile(USER_DICT, DICT_COPY)
     test_input = ["Goodbye", "-s", "S", "-d", DICT_COPY]
     try:
         main(test_input)
         self.assertFalse(diff_lines(DICT_COPY, GOOD_DICT2))
     finally:
         silent_remove(DICT_COPY, disable=DISABLE_REMOVE)
         silent_remove(DICT_BACK, disable=DISABLE_REMOVE)
示例#10
0
 def testAddNothing(self):
     # this first test does not really doing anything, and warns the user
     try:
         with capture_stderr(main, [INPUT_PATH]) as output:
             self.assertTrue(
                 "Return file will be the same as the input" in output)
         self.assertFalse(diff_lines(INPUT_PATH, DEF_OUT_PATH))
     finally:
         silent_remove(DEF_OUT_PATH, DISABLE_REMOVE)
 def testDefInp(self):
     test_input = ["-f", DEF_INPUT, "-d", ' ']
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     try:
         with capture_stdout(main, test_input) as output:
             self.assertTrue(GOOD_OUT in output)
             self.assertFalse(diff_lines(CSV_OUT, GOOD_CSV_OUT))
     finally:
         silent_remove(CSV_OUT, disable=DISABLE_REMOVE)
 def testMixedInput(self):
     """
     This input file has tuples and lists that cannot be handled by np.loadtxt
     """
     test_input = ["-f", MIXED_INPUT, "-n", "-d", ","]
     try:
         with capture_stderr(main, test_input) as output:
             self.assertTrue("could not be converted to a float" in output)
             self.assertFalse(diff_lines(MIXED_OUT, GOOD_MIXED_OUT))
     finally:
         silent_remove(MIXED_OUT, disable=DISABLE_REMOVE)
 def testAllNanInput(self):
     """
     This input file has only tuples and lists
     """
     try:
         with capture_stderr(
                 main, ["-f", ALL_NAN_INPUT, "-n", "-d", ","]) as output:
             self.assertTrue("could not be converted to a float" in output)
             self.assertFalse(diff_lines(ALL_NAN_OUT, GOOD_ALL_NAN_OUT))
     finally:
         silent_remove(ALL_NAN_OUT, logger.isEnabledFor(logging.DEBUG))
示例#14
0
 def testMakePar(self):
     # For this test, there is exactly one value provided for each parameter
     test_input = ["-c", PAR_INI]
     if logger.isEnabledFor(logging.DEBUG):
         silent_remove(PAR_OUT)
         main(test_input)
     try:
         silent_remove(PAR_OUT)
         main(test_input)
         self.assertFalse(diff_lines(PAR_OUT, GOOD_PAR_OUT))
     finally:
         silent_remove(PAR_OUT, disable=DISABLE_REMOVE)
示例#15
0
 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 testDefInpWithBuffer(self):
     try:
         test_input = ["-f", DEF_INPUT, "-b", "6", "-d", ' ']
         if logger.isEnabledFor(logging.DEBUG):
             main(test_input)
         with capture_stdout(main, test_input) as output:
             self.assertTrue(
                 'Max plus 6.0 buffer:'
                 '        17.891000        21.605000        24.314000' in
                 output)
             self.assertFalse(diff_lines(CSV_OUT, GOOD_CSV_BUFFER_OUT))
     finally:
         silent_remove(CSV_OUT, disable=DISABLE_REMOVE)
 def testCsv(self):
     """
     This input file has a header that starts with a '#' so is ignored by np.loadtxt
     """
     test_input = ["-f", CSV_INPUT, "-d", ","]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     try:
         with capture_stdout(main, test_input) as output:
             self.assertTrue(GOOD_OUT in output)
             self.assertFalse(diff_lines(CSV_OUT, GOOD_CSV_OUT))
     finally:
         silent_remove(CSV_OUT, disable=DISABLE_REMOVE)
示例#18
0
 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 testBadInput(self):
     # Test what happens when cannot convert a value to float
     #   Note: within Intellij, some values were not nan that were nan outside the environment
     #   thus, I'm not checking the output for exactly no line differences
     try:
         test_input = ["-f", BAD_INPUT, '-d', ' ']
         if logger.isEnabledFor(logging.DEBUG):
             main(test_input)
         with capture_stderr(main, test_input) as output:
             self.assertTrue("could not be converted to a float" in output)
             self.assertLess(
                 len(diff_lines(BAD_INPUT_OUT, GOOD_BAD_INPUT_OUT)), 7)
     finally:
         silent_remove(BAD_INPUT_OUT, disable=DISABLE_REMOVE)
示例#20
0
 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 testMinMax(self):
     try:
         main(["-f", MIN_MAX_INPUT, "-n", "-d", ",", "-m", MIN_MAX_FILE])
         self.assertFalse(diff_lines(MIN_MAX_OUT, GOOD_MIN_MAX_OUT))
     finally:
         silent_remove(MIN_MAX_OUT, disable=DISABLE_REMOVE)
示例#22
0
 def testSameFile(self):
     self.assertFalse(diff_lines(DIFF_LINES_BASE_FILE, DIFF_LINES_BASE_FILE))
示例#23
0
 def testDiffColNum(self):
     diff_list_line = diff_lines(DIFF_LINES_MISS_VAL, DIFF_LINES_BASE_FILE)
     self.assertEqual(len(diff_list_line), 2)
示例#24
0
 def testMissLine(self):
     diff_line_list = diff_lines(DIFF_LINES_BASE_FILE, MISS_LINES_MISS_LINE)
     self.assertEqual(len(diff_line_list), 1)
     self.assertTrue("- 540010,1.04337066817119" in diff_line_list[0])
示例#25
0
 def testDiff(self):
     diffs = diff_lines(DIFF_LINES_ONE_VAL_DIFF, DIFF_LINES_BASE_FILE)
     self.assertEqual(len(diffs), 2)
示例#26
0
 def testDiffOrd(self):
     diff_line_list = diff_lines(IMPROP_SEC, IMPROP_SEC_ALT, delimiter=" ")
     self.assertEqual(13, len(diff_line_list))
示例#27
0
 def testSciVectorsPrecDiff(self):
     self.assertFalse(diff_lines(DIFF_LINES_SCI_FILE, DIFF_LINES_ALT_SCI_FILE))
示例#28
0
 def testDiffBothNanPrecDiff(self):
     # make there also be a precision difference so the entry-by-entry comparison will be made
     diff_line_list = diff_lines(DIFF_LINES_ONE_NAN_PREC_DIFF, DIFF_LINES_ONE_NAN)
     self.assertFalse(diff_line_list)
示例#29
0
 def testDiffOneNan(self):
     diff_line_list = diff_lines(DIFF_LINES_BASE_FILE, DIFF_LINES_ONE_NAN)
     self.assertEqual(2, len(diff_line_list))
示例#30
0
 def testMachinePrecDiff2(self):
     self.assertFalse(diff_lines(DIFF_LINES_PREC_DIFF, DIFF_LINES_BASE_FILE))