From c879baa981be735ee66e5aaa402efd6fe80328bd Mon Sep 17 00:00:00 2001 From: symphony-dbcli Date: Sun, 24 May 2026 07:03:00 -0700 Subject: [PATCH] Work on dbcli/litecli#245 --- CHANGELOG.md | 4 ++++ litecli/main.py | 1 + tests/test_main.py | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index afdb40f..2c02bac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Unreleased +### Bug Fixes + +- Expand `~` in configured log file paths. + ### Internal - Add a GitHub Actions workflow to run Codex review on pull requests. diff --git a/litecli/main.py b/litecli/main.py index 8151ffa..87e1b24 100644 --- a/litecli/main.py +++ b/litecli/main.py @@ -249,6 +249,7 @@ def initialize_logging(self) -> None: log_file = self.config["main"]["log_file"] if log_file == "default": log_file = config_location() + "log" + log_file = os.path.expanduser(log_file) try: ensure_dir_exists(log_file) except OSError: diff --git a/tests/test_main.py b/tests/test_main.py index 0a47c9b..a9e757d 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -278,6 +278,23 @@ def test_startup_commands(executor): # implement tests on executions of the startupcommands +def test_log_file_expands_user_path(tmp_path, monkeypatch, capsys): + home = tmp_path / "home" + config_file = tmp_path / "liteclirc" + with open(default_config_file, encoding="utf-8") as f: + config = f.read() + config_file.write_text(config.replace("log_file = default", "log_file = ~/.cache/litecli/log"), encoding="utf-8") + + monkeypatch.setenv("HOME", str(home)) + monkeypatch.setenv("USERPROFILE", str(home)) + + LiteCli(liteclirc=str(config_file)) + + captured = capsys.readouterr() + assert "Unable to open the log file" not in captured.err + assert (home / ".cache" / "litecli" / "log").exists() + + @patch("litecli.main.datetime") # Adjust if your module path is different def test_get_prompt(mock_datetime): # We'll freeze time at 2025-01-20 13:37:42 for comedic effect.