def testDefInp(self): test_input = ["-c", DEF_INI, "-f", DEF_INPUT] try: main(test_input) self.assertFalse(diff_lines(DEF_OUT, GOOD_OUT)) finally: silent_remove(DEF_OUT, disable=DISABLE_REMOVE)
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)
def testParseError(self): # This input has a line without 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("parsing errors" in output) self.assertTrue("'col2" in output)
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 testParseError(self): # This input has a line without 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("'col2" in output)
def testInvalidHeader(self): test_input = ["-f", DEF_INPUT, "-c", INVALID_HEADER_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue("Specified column header 'run1234' was not found in file" in output)
def testInvalidKey(self): test_input = ["-f", DEF_INPUT, "-c", TYPO_INI] if logger.isEnabledFor(logging.DEBUG): main(test_input) with capture_stderr(main, test_input) as output: self.assertTrue("Unexpected key" in output)
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)