summaryrefslogtreecommitdiff
path: root/tests/unit/config/test_configcommands.py
diff options
context:
space:
mode:
authorJay Kamat <jaygkamat@gmail.com>2019-04-18 23:18:00 -0700
committerJay Kamat <jaygkamat@gmail.com>2019-07-03 17:37:13 -0700
commitf35eba0d60b0150c3a1fdf6352a958d0882b3286 (patch)
tree3a207f26ee168e769243b30b82dce791733844d3 /tests/unit/config/test_configcommands.py
parent974d762e286c8c2596ad956d54166f0c397b3ac5 (diff)
downloadqutebrowser-f35eba0d60b0150c3a1fdf6352a958d0882b3286.tar.gz
qutebrowser-f35eba0d60b0150c3a1fdf6352a958d0882b3286.zip
Use standarddir for config.py override
Also, make config-source, config-write-py, and config-edit honor config argument
Diffstat (limited to 'tests/unit/config/test_configcommands.py')
-rw-r--r--tests/unit/config/test_configcommands.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/config/test_configcommands.py b/tests/unit/config/test_configcommands.py
index 21c01ea5c..bbc3159e6 100644
--- a/tests/unit/config/test_configcommands.py
+++ b/tests/unit/config/test_configcommands.py
@@ -469,6 +469,14 @@ class TestSource:
assert ignore_case == (usertypes.IgnoreCase.smart if clear
else usertypes.IgnoreCase.always)
+ def test_config_py_arg_source(self, commands, config_py_arg, config_stub):
+ assert config_stub.val.content.javascript.enabled
+ config_stub.val.search.ignore_case = 'always'
+ config_py_arg.write_text('c.content.javascript.enabled = False\n',
+ encoding='utf-8')
+ commands.config_source()
+ assert not config_stub.val.content.javascript.enabled
+
def test_errors(self, commands, config_tmpdir):
pyfile = config_tmpdir / 'config.py'
pyfile.write_text('c.foo = 42', encoding='utf-8')
@@ -531,6 +539,15 @@ class TestEdit:
mock.assert_called_once_with(unittest.mock.ANY)
assert not config_stub.val.content.javascript.enabled
+ def test_config_py_with_sourcing(self, commands, config_stub, patch_editor, config_py_arg):
+ assert config_stub.val.content.javascript.enabled
+ conf = 'c.content.javascript.enabled = False'
+ mock = patch_editor(conf)
+ commands.config_edit()
+ mock.assert_called_once_with(unittest.mock.ANY)
+ assert not config_stub.val.content.javascript.enabled
+ assert config_py_arg.read_text('utf-8').splitlines() == [conf]
+
def test_error(self, commands, config_stub, patch_editor, message_mock,
caplog):
patch_editor('c.foo = 42')
@@ -603,6 +620,12 @@ class TestWritePy:
with pytest.raises(cmdutils.CommandError):
commands.config_write_py(str(tmpdir / 'foo' / 'config.py'))
+ def test_config_py_arg(self, commands, config_py_arg):
+ config_py_arg.ensure()
+ commands.config_write_py(str(config_py_arg), force=True)
+ lines = config_py_arg.read_text('utf-8').splitlines()
+ assert '# Autogenerated config.py' in lines
+
class TestBind: