Exemple #1
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)
Exemple #2
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)
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)
Exemple #6
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)
Exemple #7
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)
Exemple #8
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)
Exemple #9
0
 def testMakePar(self):
     # For this test, there is exactly one value provided for each parameter
     try:
         silent_remove(PAR_OUT)
         main(["-c", PAR_INI])
         self.assertFalse(diff_lines(PAR_OUT, GOOD_PAR_OUT))
     finally:
         silent_remove(PAR_OUT, disable=DISABLE_REMOVE)
Exemple #10
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)
Exemple #11
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)
Exemple #12
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)
Exemple #13
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)
Exemple #14
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)
Exemple #15
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)