Пример #1
0
 def testSaveSmi(self):
     try:
         test_input = ["-r", "10", "-o", TEST_SMI_BASENAME, "-d", SUB_DATA_DIR, "-a", "1.0"]
         main(test_input)
         self.assertFalse(diff_lines(TEST_SMI_OUT, GOOD_TEST_SMI_OUT))
     finally:
         silent_remove(TEST_SMI_OUT, disable=DISABLE_REMOVE)
         pass
Пример #2
0
 def testHelp(self):
     test_input = ['-h']
     # main(test_input)
     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)
Пример #3
0
 def testTCLGenOptions(self):
     try:
         test_input = ["-r", "8", "-i", "4", "-m", "4", "-f", "tcl", "-d", SUB_DATA_DIR,
                       "--chain_id", "1", "--psf_fname", "birch", "--toppar_dir", "", "-a", "1.0", "-x"]
         main(test_input)
         self.assertFalse(diff_lines(DEF_TCL_OUT, GOOD_TCL_OPTIONS_OUT))
     finally:
         silent_remove(DEF_TCL_OUT, disable=DISABLE_REMOVE)
         pass
Пример #4
0
 def testDirInBasename(self):
     # This should ignore the temp_dir; will throw error if it doesn't
     try:
         test_input = ["-r", "10", "-o", TEST_SMI_OUT, "-d", TEMP_DIR, "-a", "1.0"]
         main(test_input)
         self.assertFalse(diff_lines(TEST_SMI_OUT, GOOD_TEST_SMI_OUT))
     finally:
         silent_remove(TEST_SMI_OUT, disable=DISABLE_REMOVE)
         pass
Пример #5
0
 def testBadConfigFile(self):
     test_input = ["-c", "ghost.ini"]
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Could not find specified configuration file" in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
Пример #6
0
 def testUnrecognizedArg(self):
     test_input = ['-@']
     # main(test_input)
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("unrecognized argument" in output)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("optional arguments" in output)
Пример #7
0
 def testSaveJSON(self):
     try:
         silent_remove(DEF_JSON_OUT)
         test_input = ["-r", "10", "-f", "json", "-d", SUB_DATA_DIR, "-a", "1.0"]
         main(test_input)
         with open(DEF_JSON_OUT, "r") as f:
             json_str = f.readlines()
         self.assertTrue(GOOD_JSON_PARTS[0] in json_str[0])
     finally:
         silent_remove(DEF_JSON_OUT, disable=DISABLE_REMOVE)
Пример #8
0
 def testMakeSubDir(self):
     try:
         test_input = ["-r", "10", "-d", TEMP_DIR, "-o", TEST_SMI_BASENAME, "-a", "1.0"]
         main(test_input)
         self.assertFalse(diff_lines(TEST_SMI_OUT_TEMP_DIR, GOOD_TEST_SMI_OUT))
     finally:
         silent_remove(TEST_SMI_OUT_TEMP_DIR, disable=DISABLE_REMOVE)
         silent_remove(TEMP_DIR, dir_with_files=True, disable=DISABLE_REMOVE)
         silent_remove(INNER_TEMP_DIR, disable=DISABLE_REMOVE)
         pass
Пример #9
0
 def testSavePNGSVGNewSize(self):
     # Smoke test only (not comparing images)
     try:
         test_input = ["-r", "10", "-f", "png, svg", "-d", SUB_DATA_DIR, "-s", "(900, 900)"]
         main(test_input)
         self.assertTrue(os.path.isfile(DEF_PNG_OUT))
         self.assertTrue(os.path.isfile(DEF_SVG_OUT))
     finally:
         silent_remove(DEF_PNG_OUT, disable=DISABLE_REMOVE)
         silent_remove(DEF_SVG_OUT, disable=DISABLE_REMOVE)
         pass
Пример #10
0
 def testSaveJSONPathInOutName(self):
     try:
         silent_remove(DEF_JSON_OUT)
         test_input = ["-r", "10", "-f", "json", "-o", DEF_JSON_OUT, "-a", "1.0"]
         main(test_input)
         with open(DEF_JSON_OUT, "r") as f:
             json_str = f.readlines()
         for json_part in GOOD_JSON_PARTS:
             self.assertTrue(json_part in json_str[0])
     finally:
         silent_remove(DEF_JSON_OUT, disable=DISABLE_REMOVE)
         pass
Пример #11
0
 def testSavePNGSVG(self):
     # Smoke test only (not comparing images)
     try:
         silent_remove(DEF_PNG_OUT)
         silent_remove(DEF_SVG_OUT)
         test_input = ["-r", "10", "-f", "svg", "-o", DEF_BASENAME + '.png', "-d", SUB_DATA_DIR, "-m", "6",
                       "-s", "900 900"]
         main(test_input)
         self.assertTrue(os.path.isfile(DEF_PNG_OUT))
         self.assertTrue(os.path.isfile(DEF_SVG_OUT))
     finally:
         silent_remove(DEF_PNG_OUT, disable=DISABLE_REMOVE)
         silent_remove(DEF_SVG_OUT, disable=DISABLE_REMOVE)
Пример #12
0
 def testSGPlot3(self):
     # also has multiple sg_ratio; smoke test only (that files are created, but not testing content
     expected_files = [PLOT_BOND_V_SG6_PNG, PLOT_BOND_V_SG8_PNG]
     try:
         for fname in expected_files:
             silent_remove(fname)
         test_input = ["-r", "6", "-i", "8", "-m", "16", "-a", "1e8, 1e6", "-sg", "5,10",
                       "-n", "3", "-p", "-d", PLOT_DIR, "-x"]
         main(test_input)
         for fname in expected_files:
             self.assertTrue(os.path.isfile(fname))
     finally:
         silent_remove(TEMP_DIR, dir_with_files=True, disable=DISABLE_REMOVE)
         pass
Пример #13
0
 def testSaveJSONCommaPNG(self):
     # Smoke test on png with default image size
     try:
         silent_remove(DEF_PNG_OUT)
         silent_remove(DEF_JSON_OUT)
         test_input = ["-r", "10", "-f", "json, png", "-d", SUB_DATA_DIR, "-a", "1.0"]
         main(test_input)
         self.assertTrue(os.path.isfile(DEF_PNG_OUT))
         with open(DEF_JSON_OUT, "r") as f:
             json_str = f.readlines()
         self.assertTrue(GOOD_JSON_PARTS[0] in json_str[0])
     finally:
         silent_remove(DEF_PNG_OUT, disable=DISABLE_REMOVE)
         silent_remove(DEF_JSON_OUT, disable=DISABLE_REMOVE)
         pass