tests: Add quteproc.temp_setting.
This commit is contained in:
parent
e6eaa5f140
commit
52aca30342
@ -29,6 +29,7 @@ import os.path
|
|||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import contextlib
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
import pytest
|
import pytest
|
||||||
@ -215,6 +216,14 @@ class QuteProc(testprocess.Process):
|
|||||||
self.send_cmd(':set "{}" "{}" "{}"'.format(sect, opt, value))
|
self.send_cmd(':set "{}" "{}" "{}"'.format(sect, opt, value))
|
||||||
self.wait_for(category='config', message='Config option changed: *')
|
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):
|
def open_path(self, path, new_tab=False):
|
||||||
url = self._path_to_url(path)
|
url = self._path_to_url(path)
|
||||||
if new_tab:
|
if new_tab:
|
||||||
|
Loading…
Reference in New Issue
Block a user