Ejemplo n.º 1
0
 def testMissingMain(self):
     # make sure it gracefully fails when a template key is missing
     test_input = ["-c", MISSING_MAIN_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("missing the required 'main' section" in output)
Ejemplo n.º 2
0
 def testExtraSection(self):
     # catch an error if the program finds an unexpected section
     test_input = ["-c", EXTRA_SEC_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('not one of the valid section names' in output)
Ejemplo n.º 3
0
 def testMissingTplKey(self):
     # make sure it gracefully fails when a template key is missing
     test_input = ["-c", MISSING_TPL_KEY_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('required for template file' in output)
Ejemplo n.º 4
0
 def testValBeforeSection(self):
     # make sure it gracefully fails when a template key is missing
     test_input = ["-c", VAL_BEFORE_SECTION_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('must start with' in output)
Ejemplo n.º 5
0
 def testTplKeyInMain(self):
     # aim for a helpful message if the template key is in main
     test_input = ["-c", TPL_KEY_IN_MAIN_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('Unexpected key' in output)
Ejemplo n.º 6
0
 def testMissingFilledTplName(self):
     # new file name not specified by either config file or command line
     test_input = ["-c", PAR_NO_NEW_FILE_NAME_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue(FILLED_TPL_FNAME in output)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
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)
Ejemplo n.º 12
0
 def testMakeParEqMissingParam(self):
     test_input = ["-c", PAR_EQ_MISS_PARAM_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('Missing parameter value' in output)
Ejemplo n.º 13
0
 def testMakeParEqWrongOrder(self):
     test_input = ["-c", PAR_EQ_WRONG_ORDER_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('Check order' in output)
Ejemplo n.º 14
0
 def testMakeParMissingKeyFileName(self):
     test_input = ["-c", PAR_NO_NEW_FILE_NAME_INI, "-f", '{ghost}.par']
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue('required for filled template file name' in output)
Ejemplo n.º 15
0
 def testMissingTpl(self):
     test_input = ["-c", MISSING_TPL_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("template file specified" in output)