fix: Correctly parse boolean config options set to false
Previously, when parsing config options that were set to 'false', e.g. `TOPEN_NOTES_QUIET=false` in the env vars, we would still be setting it to true. This change fixes any falsy value to be correctly parsed as False.
This commit is contained in:
parent
6517eb3971
commit
ff0e6cccfb
2 changed files with 46 additions and 3 deletions
|
|
@ -63,6 +63,16 @@ class TestEnv:
|
|||
assert env["task_rc"] == Path("/a/dir/that/dont/exist/file")
|
||||
assert env["task_data"] == Path("~/somewhere/tasks")
|
||||
|
||||
def test_env_parses_boolean_true(self, isolate_env, monkeypatch):
|
||||
monkeypatch.setenv("TOPEN_NOTES_QUIET", "true")
|
||||
env = parse_env()
|
||||
assert env["notes_quiet"] is True
|
||||
|
||||
def test_env_parses_boolean_false(self, isolate_env, monkeypatch):
|
||||
monkeypatch.setenv("TOPEN_NOTES_QUIET", "false")
|
||||
env = parse_env()
|
||||
assert env["notes_quiet"] is False
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fake_rc(tmp_path: Path, monkeypatch):
|
||||
|
|
@ -89,6 +99,20 @@ class TestRcFile:
|
|||
assert rc_cfg["notes_editor"] == "micro"
|
||||
assert rc_cfg["notes_quiet"] is True
|
||||
|
||||
def test_taskrc_parses_boolean_true(self, fake_rc):
|
||||
fake_rc.write_text("""
|
||||
notes.quiet=true
|
||||
""")
|
||||
rc_cfg = parse_rc(fake_rc)
|
||||
assert rc_cfg["notes_quiet"] is True
|
||||
|
||||
def test_taskrc_parses_boolean_false(self, fake_rc):
|
||||
fake_rc.write_text("""
|
||||
notes.quiet=false
|
||||
""")
|
||||
rc_cfg = parse_rc(fake_rc)
|
||||
assert rc_cfg["notes_quiet"] is False
|
||||
|
||||
|
||||
class TestTConf:
|
||||
def test_paths_are_expanded(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue