def test_rename_with_regex(self):
     # Test that renameto works with a regular expression as the match string
     a = RenameTo({'match': '^[a-z][a-z]c_', 'replace-with': ''})
     new_filename = a.do_action(self.source_file)
     self.assertEqual(self.destination_file, new_filename)
     self.assertTrue(os.path.isfile(self.destination_file),
                     "Destination file does not exist")
     self.assertFalse(os.path.isfile(self.source_file),
                      "Source file still exists")
    def setUp(self):
        # Make a temp directory and test file
        self.source_dir = tempfile.mkdtemp()

        self.test_filename = "abc_test.txt"
        self.destination_filename = "test.txt"
        self.source_file = os.path.join(self.source_dir, self.test_filename)
        self.destination_file = os.path.join(self.source_dir,
                                             self.destination_filename)

        with open(self.source_file, 'w') as output:
            output.write("This is a test file.")

        self.action = RenameTo({'match': 'abc_', 'replace-with': ''})
 def test_replace_with_parameter_is_none(self):
     # If replace-with is None, the replace-with value should be an empty string
     a = RenameTo({'match': 'abc', 'replace-with': None})
     self.assertEqual('', a.replace_with)