예제 #1
0
 def testBinTooMany(self):
     test_input = ["-f", DEF_INPUT, "-c", BIN_TOO_MANY_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Expected a comma-separated list of length 3 or 4 for section 'bin_settings' key 'cv'. "
                         "Read: 0.5,0.7,2,6,10" in output)
예제 #2
0
 def testWrongFileToFilter(self):
     # If put a configuration file as the file to read, fail well
     test_input = ["-f", DEF_INI, "-c", DEF_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("could not convert string" in output)
예제 #3
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)
예제 #4
0
 def testBinMax2(self):
     # In this input, both bins have more than the max entries
     test_input = ["-f", BIN_INPUT, "-c", BIN_MAX2_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(DEF_BIN_OUT, GOOD_BIN_MAX2_OUT))
     finally:
         silent_remove(DEF_BIN_OUT, disable=DISABLE_REMOVE)
예제 #5
0
 def testBinMax(self):
     # In this input, one big has more than the max and one less
     test_input = ["-f", BIN_INPUT, "-c", BIN_MAX_INI]
     try:
         main(test_input)
         # self.assertFalse(diff_lines(DEF_BIN_OUT, GOOD_BIN_MAX_OUT))
     finally:
         silent_remove(DEF_BIN_OUT, disable=DISABLE_REMOVE)
예제 #6
0
 def testNoMinNonFloat(self):
     # Tests both handling when no min section is specified and non-floats in the file to be analyzed
     test_input = ["-f", NON_FLOAT_INPUT, "-c", NO_MIN_INI]
     try:
         main(test_input)
         self.assertFalse(diff_lines(NON_FLOAT_OUT, GOOD_NON_FLOAT_OUT))
     finally:
         silent_remove(NON_FLOAT_OUT)
예제 #7
0
 def testParseError(self):
     # This input has a line with only "z" (no equals), resulting in a parsing error we will catch
     test_input = ["-f", DEF_INPUT, "-c", PARSE_ERROR_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("File contains parsing errors" in output)
         self.assertTrue("'z" in output)
예제 #8
0
 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)
예제 #9
0
 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)
예제 #10
0
 def testInvalidKey(self):
     test_input = ["-f", DEF_INPUT, "-c", INVALID_KEY_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Unexpected key" in output)
예제 #11
0
 def testNoSuchFile(self):
     test_input = ["-f", "ghost.csv", "-c", DEF_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("Problems reading file" in output)
예제 #12
0
 def testBinNonInt(self):
     test_input = ["-f", DEF_INPUT, "-c", BIN_NONINT_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("could not convert '0.2' to" in output)
예제 #13
0
 def testBinNegInt(self):
     test_input = ["-f", DEF_INPUT, "-c", BIN_NEG_INT_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("positive integers are required" in output)
예제 #14
0
 def testNonfloatKeyValue(self):
     test_input = ["-f", DEF_INPUT, "-c", NONFLOAT_KEY_INI]
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("For section 'min_vals' key 'z', could not convert value '' to a float" in output)