def testDo(self):
     o = renamer.RenameInFile(self._path, 'is is a', 'at was some')
     o.do()
     with open(self._path) as f:
         output = f.read()
     self.assertEqual(output, 'That was some test\nThat was somenother\n')
     os.unlink(self._path)
Beispiel #2
0
 def testSerialize(self):
     o = renamer.RenameInFile(self._path, 'is is a', 'at was some')
     data = o.serialize()
     o2 = renamer.RenameInFile.deserialize(data)
     o2.do()
     output = open(self._path).read()
     self.assertEqual(output, 'That was some test\nThat was somenother\n')
     os.unlink(self._path)
Beispiel #3
0
    def setUp(self):
        self._statePath = tempfile.mkdtemp(suffix='.whipper.renamer.operator')
        self._operator = renamer.Operator(self._statePath, 'test')

        (fd,
         self._source) = tempfile.mkstemp(suffix='.whipper.renamer.operator')
        os.write(fd, 'This is a test\nThis is another\n')
        os.close(fd)
        (fd, self._destination) = tempfile.mkstemp(
            suffix='.whipper.renamer.operator')
        os.close(fd)
        os.unlink(self._destination)
        self._operator.addOperation(
            renamer.RenameInFile(self._source, 'is is a', 'at was some'))
        self._operator.addOperation(
            renamer.RenameFile(self._source, self._destination))
Beispiel #4
0
 def testVerify(self):
     o = renamer.RenameInFile(self._path, 'is is a', 'at was some')
     self.assertEqual(o.verify(), None)
     os.unlink(self._path)
     self.assertRaises(AssertionError, o.verify)