def test_unregistering_file_that_had_never_been_registered_fails(self):
     with self.assertRaisesRegexp(RuntimeError,
                                  'No backup registered for the given path:'
                                  ' .*'):
         BackupEditAndRestore._unregister(self._context_name,
                                          self._existing_path,
                                          None)
    def test_unregistering_file_with_wrong_instance_fails(self):
        with BackupEditAndRestore(self._context_name,
                                  self._existing_path,
                                  'w+') as self._f:
            pass

        with self.assertRaisesRegexp(RuntimeError,
                                     'Registered and passed instances .*'):
            BackupEditAndRestore._unregister(self._context_name,
                                             self._existing_path,
                                             None)