Exemple #1
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 #2
0
 def testAltPattern(self):
     make_files(TEST_FILE_NAMES)
     test_input = ["-d", SUB_DATA_DIR, "-p", "!", "-n", "_"]
     initial_fnames = add_sub_dir(TEST_FILE_NAMES, SUB_DATA_DIR)
     expected_fnames = add_sub_dir(REPLACED_FILE_NAMES2, SUB_DATA_DIR)
     try:
         if logger.isEnabledFor(logging.DEBUG):
             main(test_input)
             # need to make again for capturing std out
             make_files(TEST_FILE_NAMES)
         with capture_stdout(main, test_input) as output:
             self.assertTrue("Found and renamed 1 files" in output)
         self.assertTrue(count_files(initial_fnames), 1)
         self.assertTrue(count_files(expected_fnames), 3)
     finally:
         for fname in expected_fnames:
             silent_remove(fname, disable=DISABLE_REMOVE)
Exemple #3
0
 def testNoFilesRenamed(self):
     test_input = []
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stdout(main, test_input) as output:
         self.assertTrue("Found and renamed 0 files" in output)
Exemple #4
0
 def testInvalidArg(self):
     test_input = ['-@']
     if logger.isEnabledFor(logging.DEBUG):
         main(test_input)
     with capture_stderr(main, test_input) as output:
         self.assertTrue("unrecognized arguments" in output)