tests: Add quteproc.temp_setting.

This commit is contained in:
Florian Bruhin 2015-11-23 13:31:17 +01:00
parent e6eaa5f140
commit 52aca30342

View File

@ -29,6 +29,7 @@ import os.path
import datetime
import logging
import tempfile
import contextlib
import yaml
import pytest
@ -215,6 +216,14 @@ class QuteProc(testprocess.Process):
self.send_cmd(':set "{}" "{}" "{}"'.format(sect, opt, value))
self.wait_for(category='config', message='Config option changed: *')
@contextlib.contextmanager
def temp_setting(self, sect, opt, value):
"""Context manager to set a setting and reset it on exit."""
old_value = self.get_setting(sect, opt)
self.set_setting(sect, opt, value)
yield
self.set_setting(sect, opt, old_value)
def open_path(self, path, new_tab=False):
url = self._path_to_url(path)
if new_tab: