def testNoArgs(self): with capture_stderr(main, []) as output: self.assertTrue( "WARNING: Problems reading file: Could not read file" in output) with capture_stdout(main, []) as output: self.assertTrue("optional arguments" in output)
def testDefInp(self): try: with capture_stdout(main, ["-f", DEF_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 testMultFileToPDBXYZ(self): # When checking output, ignore differences in version and time try: test_input = ["-c", MULT_2PDB_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue( '"tests/test_data/cp2k_proc/glu_2.5_1.0.out",-283.341542,"False","False"' in output) self.assertTrue( '"tests/test_data/cp2k_proc/glu_2.5_1.05-1.out",-283.526959,"True","True"' in output) diffs = diff_lines(GLU_PDB_OUT, GOOD_GLU_PDB_OUT) diffs1 = diff_lines(GLU_PDB_OUT2, GOOD_GLU_PDB_OUT2) for diff_list in [diffs, diffs1]: self.assertEqual(len(diff_list), 2) self.assertTrue("Created on " in diff_list[0]) self.assertFalse(diff_lines(GLU_XYZ_OUT, GOOD_GLU_XYZ_OUT)) finally: silent_remove(GLU_PDB_OUT, disable=DISABLE_REMOVE) silent_remove(GLU_PDB_OUT1, disable=DISABLE_REMOVE) silent_remove(GLU_PDB_OUT2, disable=DISABLE_REMOVE) silent_remove(GLU_XYZ_OUT, disable=DISABLE_REMOVE) silent_remove(GLU_XYZ_OUT1, disable=DISABLE_REMOVE) silent_remove(GLU_XYZ_OUT2, disable=DISABLE_REMOVE)
def testDefInp(self): try: with capture_stdout(main, ["-f", DEF_INPUT, "-c", DEF_INI]) as output: self.assertTrue("Keeping 2 of 4 rows based on filtering criteria" in output) self.assertFalse(diff_lines(CSV_OUT, GOOD_CSV_OUT)) finally: silent_remove(CSV_OUT)
def testMissingFileList(self): test_input = ["-l", " "] with capture_stdout(main, test_input) as output: self.assertTrue("show this help message" in output) with capture_stderr(main, test_input) as output: self.assertTrue( "Specified file listing cp2k force files missing" in output)
def testNoIni(self): test_input = [] with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments:" in output) with capture_stderr(main, test_input) as output: self.assertTrue( "Problems reading file: Could not read file" in output)
def testMaxTimestepsCalcHIJ(self): try: with capture_stdout(main, ["-c", HIJ_INI]) as output: self.assertTrue("Reached the maximum timesteps" in output) self.assertFalse(diff_lines(HIJ_OUT, GOOD_HIJ_OUT)) finally: silent_remove(HIJ_OUT, disable=DISABLE_REMOVE)
def testNoSuchOption(self): # main(["-@", DEF_OUT]) with capture_stderr(main, ["-@", DEF_OUT]) as output: self.assertTrue("unrecognized argument" in output) self.assertTrue(DEF_OUT in output) with capture_stdout(main, ["-@", DEF_OUT]) as output: self.assertTrue("optional arguments" in output)
def testCheckCharge(self): try: with capture_stdout(main, ["-c", CHECK_CHARGE_INI]) as output: self.assertFalse("total charge" in output) finally: silent_remove(VMD_OUT) silent_remove(WATER_OUT)
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 testNoArgs(self): test_input = [] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue("Could not read file" in output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
def testDefInpWithBuffer(self): try: with capture_stdout(main, ["-f", DEF_INPUT, "-b", "6"]) 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 testMissingConfig(self): test_input = ["-c", INCOMP_INI_PATH] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue("Missing config val" in output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
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 testNoIni(self): test_input = [] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue("usage:" in output) with capture_stderr(main, test_input) as output: self.assertTrue("Problems reading file: Could not read file" in output)
def testMissingInfo(self): test_input = ["-c", INCOMP_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue("Missing config val for key 'prot_res_mol_id'" in output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
def testNoArgs(self): test_input = [] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue("arguments:" in output) with capture_stderr(main, test_input) as output: self.assertTrue("required" in output)
def testInvalidData(self): test_input = ["-c", INVALID_INI] with capture_stderr(main, test_input) as output: self.assertTrue( "Problem with config vals on key h3o_o_type: invalid literal for int" in output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
def testMissingConfig(self): test_input = ["-c", INCOMP_INI_PATH] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue("Missing config val for key 'water_o_type'" in output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
def testNoIni(self): test_input = [] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue("usage:" in output) with capture_stderr(main, test_input) as output: self.assertTrue( "Problems reading file: Could not read file" in output)
def testMissingInfo(self): test_input = ["-c", INCOMP_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue( "Missing config val for key 'prot_res_mol_id'" in output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
def testNoSuchOption(self): test_input = ["-@", DEF_OUT] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue("unrecognized argument" in output) self.assertTrue(DEF_OUT in output) with capture_stdout(main, test_input) as output: self.assertTrue("optional arguments" in output)
def testCheckCharge(self): try: test_input = ["-c", CHECK_CHARGE_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertFalse("total charge" in output) finally: silent_remove(VMD_OUT, disable=DISABLE_REMOVE) silent_remove(WATER_OUT, disable=DISABLE_REMOVE)
def testHO_OO_HH_OHGofR_MaxSteps(self): test_input = ["-c", HO_OO_HH_OH_GOFR_INI_MAX_STEPS] if logger.isEnabledFor(logging.DEBUG): main(test_input) try: with capture_stdout(main, test_input) as output: self.assertTrue(good_long_out_msg in output) self.assertFalse(diff_lines(DEF_MAX_STEPS_OUT, GOOD_HO_OO_HH_OH_GOFR_OUT_MAX_STEPS)) finally: silent_remove(DEF_MAX_STEPS_OUT, disable=DISABLE_REMOVE)
def testCsvHeader(self): """ This input file has a header that starts with a '#' so is ignored by np.loadtxt """ try: with capture_stdout(main, ["-f", CSV_HEADER_INPUT, "-n", "-d", ","]) as output: self.assertTrue(GOOD_OUT in output) self.assertFalse(diff_lines(CSV_HEADER_OUT, GOOD_CSV_HEADER_OUT)) finally: silent_remove(CSV_HEADER_OUT, disable=DISABLE_REMOVE)
def testMMAfterQM(self): test_input = ["-f", GLU_FILE_MM_AFTER_QM, "-n", GLU_ATOM_NUM] if logger.isEnabledFor(logging.DEBUG): main(test_input) try: with capture_stdout(main, test_input) as output: self.assertTrue("1429 44 0.065 -0.677 -0.401 0.789" in output) self.assertFalse(diff_lines(GLU_2MM_AFTER_QM_OUT, GOOD_GLU_2QM_OUT, delimiter=" ")) finally: silent_remove(GLU_2MM_AFTER_QM_OUT, disable=DISABLE_REMOVE)
def testRelativeEnergy(self): try: test_input = ["-c", REL_E_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue("44.822" in output) self.assertFalse(diff_lines(REL_E_OUT, GOOD_REL_E_OUT)) finally: silent_remove(REL_E_OUT, disable=DISABLE_REMOVE)
def testGood(self): try: # main(["-c", DEF_INI]) with capture_stdout(main, ["-c", DEF_INI]) as output: self.assertTrue("total charge" in output) self.assertFalse(diff_lines(VMD_OUT, GOOD_VMD_OUT)) self.assertFalse(diff_lines(WATER_OUT, GOOD_WATER_OUT)) finally: silent_remove(VMD_OUT) silent_remove(WATER_OUT)
def testBin(self): test_input = ["-f", BIN_INPUT, "-c", BIN_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) try: with capture_stdout(main, test_input) as output: self.assertTrue("Keeping 14 of 16 rows based on filtering criteria" in output) self.assertFalse(diff_lines(DEF_BIN_OUT, GOOD_BIN_OUT)) finally: silent_remove(DEF_BIN_OUT, disable=DISABLE_REMOVE)
def testGoodAtomNumFile(self): test_input = ["-f", GLU_FILE, "-n", GLU_ATOM_NUM] main(test_input) if logger.isEnabledFor(logging.DEBUG): main(test_input) try: with capture_stdout(main, test_input) as output: self.assertTrue("1429 47 -0.215 0.156 -0.387 0.470" in output) self.assertFalse(diff_lines(GLU_OUT1, GOOD_GLU_OUT1, delimiter=" ")) finally: silent_remove(GLU_OUT1, disable=DISABLE_REMOVE)
def testRMSDEnergy(self): try: test_input = ["-c", RMSD_ENE_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue("23.760125" in output) print(REL_ENE_OUT2) print(GOOD_RMSD_ENE_OUT) self.assertFalse(diff_lines(REL_ENE_OUT2, GOOD_RMSD_ENE_OUT)) finally: silent_remove(REL_ENE_OUT2, disable=DISABLE_REMOVE)
def testGood(self): try: test_input = ["-c", DEF_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue("total charge" in output) self.assertFalse(diff_lines(VMD_OUT, GOOD_VMD_OUT)) self.assertFalse(diff_lines(WATER_OUT, GOOD_WATER_OUT)) finally: silent_remove(VMD_OUT) silent_remove(WATER_OUT)
def testCsv(self): """ This input file has a header that starts with a '#' so is ignored by np.loadtxt """ if logger.isEnabledFor(logging.DEBUG): main(["-f", CSV_INPUT, "-d", ","]) try: with capture_stdout(main, ["-f", CSV_INPUT, "-d", ","]) 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 testDupKey(self): # Checking what happens if the key is listed twice. Expect the program to use the last # key value. In this case, it results in no rows that meet the criteria test_input = ["-f", DEF_INPUT, "-c", DUP_KEY_INI] try: if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stdout(main, test_input) as output: self.assertTrue("Keeping 0 of 4 rows based on filtering criteria" in output) self.assertFalse(diff_lines(CSV_OUT, GOOD_CSV_NONE_KEPT)) finally: silent_remove(CSV_OUT, disable=DISABLE_REMOVE)
def testPrintQMMM(self): try: # main(["-c", QMMM_OUT_INI]) with capture_stdout(main, ["-c", QMMM_OUT_INI]) as output: self.assertTrue("Total charge from QM atoms: -1.0" in output) self.assertFalse(diff_lines(QMMM_OUT, GOOD_QMMM_OUT)) self.assertFalse(diff_lines(MM_KIND_OUT, GOOD_MM_KIND_OUT)) self.assertFalse(diff_lines(VMD_ATOMS_OUT, GOOD_VMD_ATOMS_OUT)) finally: silent_remove(QMMM_OUT) silent_remove(MM_KIND_OUT) silent_remove(VMD_ATOMS_OUT)
def testHO_OO_HH_OHGofR_MaxSteps(self): test_input = ["-c", HO_OO_HH_OH_GOFR_INI_MAX_STEPS] if logger.isEnabledFor(logging.DEBUG): main(test_input) try: with capture_stdout(main, test_input) as output: self.assertTrue(good_long_out_msg in output) self.assertFalse( diff_lines(DEF_MAX_STEPS_OUT, GOOD_HO_OO_HH_OH_GOFR_OUT_MAX_STEPS)) finally: silent_remove(DEF_MAX_STEPS_OUT, disable=DISABLE_REMOVE)
def testMissingIncompleteFile(self): test_input = ["-l", INCOMP_F_LIST] if logger.isEnabledFor(logging.DEBUG): main(test_input) try: with capture_stderr(main, test_input) as output: self.assertTrue("Check file" in output) self.assertTrue("Could not read file" in output) with capture_stdout(main, test_input) as output: self.assertTrue("1429 47 -0.215 0.156 -0.387 0.470" in output) self.assertFalse(diff_lines(GLU_OUT1, GOOD_GLU_OUT1, delimiter=" ")) finally: silent_remove(GLU_OUT1)
def testBasinHopBounds(self): # Try hopping + minimization try: silent_remove(SCRIPT_OUT) test_input = ["-c", CONV_HOP_MIN_MAX_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) silent_remove(SCRIPT_OUT) with capture_stdout(main, test_input) as output: self.assertTrue("success condition satisfied. Number of function calls: 83" in output) finally: silent_remove(PAR_OUT, disable=DISABLE_REMOVE) silent_remove(SCRIPT_OUT, disable=DISABLE_REMOVE)
def testHIJArq6(self): # Test calculating the Maupin form try: test_input = ["-c", HIJ_ARQ6_GLU2_INI, "-p"] if logger.isEnabledFor(logging.DEBUG): main(test_input) # because i've turned off printing, there should be no output with capture_stdout(main, test_input) as output: self.assertFalse(output) self.assertFalse( diff_lines(HIJ_NEW_GLU2_OUT, GOOD_HIJ_NEW_GLU2_OUT)) finally: silent_remove(HIJ_NEW_GLU2_OUT, disable=DISABLE_REMOVE)
def testHeader(self): """ This input file has a header that starts with a '#' so is ignored by np """ test_input = ["-f", HEADER_INPUT] 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_HEADER_OUT, GOOD_CSV_OUT)) finally: silent_remove(CSV_HEADER_OUT, disable=DISABLE_REMOVE)
def testNoInputFile(self): with capture_stderr(main) as output: self.assertTrue("Problems reading file: Could not read file" in output) with capture_stdout(main) as output: self.assertTrue("optional arguments" in output)
def testHelpOption(self): with capture_stdout(main, ["-h"]) as output: self.assertTrue("optional arguments" in output)
def testNoArgs(self): with capture_stdout(main, []) as output: self.assertTrue("usage:" in output) with capture_stderr(main, []) as output: self.assertTrue("too few arguments" in output)
def testNoAction(self): with capture_stderr(main, ["-c", NO_ACTION_INI_PATH]) as output: self.assertTrue("No calculations have been requested" in output) with capture_stdout(main, ["-c", NO_ACTION_INI_PATH]) as output: self.assertTrue("optional arguments" in output)
def testNoArgsIni(self): # main([]) with capture_stdout(main, []) as output: self.assertTrue("optional arguments:" in output) with capture_stderr(main, []) as output: self.assertTrue("Problems reading file: Could not read file" in output)
def testMissingConfig(self): with capture_stderr(evbdump2data.main, ["-c", INCOMP_INI]) as output: self.assertTrue("Input data missing" in output) with capture_stdout(evbdump2data.main, ["-c", INCOMP_INI]) as output: self.assertTrue("optional arguments" in output)
def testNoIni(self): with capture_stdout(evbdump2data.main, []) as output: self.assertTrue("usage:" in output) with capture_stderr(evbdump2data.main, []) as output: self.assertTrue("Problems reading file: Could not read file" in output)
def testNoArgs(self): with capture_stdout(main, []) as output: self.assertTrue("optional arguments" in output) with capture_stderr(main, []) as output: self.assertTrue("Problems reading file" in output)
def testNoComboFiles(self): with capture_stdout(main, ["-d", FES_OUT_NONE]) as output: self.assertTrue("Found 0 dirs with files to combine" in output)
def testInvalidData(self): with capture_stderr(main, ["-c", INVALID_INI]) as output: self.assertTrue("Problem with config vals on key h3o_o_type: invalid literal for int" in output) with capture_stdout(main, ["-c", INVALID_INI]) as output: self.assertTrue("optional arguments" in output)
def testNoArgs(self): with capture_stderr(main, []) as output: self.assertTrue("Could not read file" in output) with capture_stdout(main, []) as output: self.assertTrue("optional arguments" in output)