예제 #1
0
파일: actions.py 프로젝트: chrisboyd/lokole
    def _wvdial_log(self) -> Path:
        wvdial_log = self._state_dir / 'wvdial.log'

        backup(wvdial_log)

        wvdial_log.write_bytes(b'')
        return wvdial_log
예제 #2
0
    def test_backup(self):
        fobj = NamedTemporaryFile(delete=False)
        fobj.close()
        path = Path(fobj.name)
        try:
            path.write_bytes(b'foo\n')
            backup(path)

            path.write_bytes(b'bar')
            backup(fobj.name)

            path.write_bytes(b'\nbaz')
            backup_path = backup(fobj.name)

            self.assertIsNotNone(backup_path)
            self.assertTrue(backup_path.is_file())

            with GzipFile(str(backup_path), 'rb') as fobj:
                self.assertEqual(fobj.read(), b'foo\nbar\nbaz')
        finally:
            remove(fobj.name)
예제 #3
0
 def test_backup_without_file(self):
     path = '/does/not/exist.txt'
     backup_path = backup(path, suffix='.old')
     self.assertIsNone(backup_path)
     self.assertFalse(Path('{}.old'.format(path)).is_file())