From 83e2aa7ea1924d4141cd49dc43634199f70932f6 Mon Sep 17 00:00:00 2001 From: Kevin Weiss Date: Wed, 30 Sep 2026 11:06:57 +0200 Subject: [PATCH] fix(hlpr): pass the end keyword of lob_print to print lob_print popped end before printing, so lob_print(path, "x", end="") still printed a newline. Leave it in the print kwargs; the log file side never used it. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/lob_hlpr/hlpr.py | 1 - tests/test_lob_hlpr.py | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lob_hlpr/hlpr.py b/src/lob_hlpr/hlpr.py index 2fb976b..b56e376 100644 --- a/src/lob_hlpr/hlpr.py +++ b/src/lob_hlpr/hlpr.py @@ -136,7 +136,6 @@ def lob_print(log_path: str, *args, **kwargs): """ color = kwargs.pop("color", None) sep = kwargs.pop("sep", " ") - kwargs.pop("end", None) # consumed by print, not meaningful for logging LobHlpr._print_color(*args, color=color, sep=sep, **kwargs) # get the directory from the log_path diff --git a/tests/test_lob_hlpr.py b/tests/test_lob_hlpr.py index 769489a..7d190e1 100644 --- a/tests/test_lob_hlpr.py +++ b/tests/test_lob_hlpr.py @@ -188,6 +188,14 @@ def test_log_print_multiline(tmp_path, capsys): assert not any("\n" in ln for ln in log_lines) +@pytest.mark.parametrize("color", [None, "red"]) +def test_log_print_end(tmp_path, capsys, color): + """The end keyword reaches print, with and without color.""" + test_file = tmp_path / "end.log" + hlp.lob_print(str(test_file), "no newline", end="", color=color) + assert not capsys.readouterr().out.endswith("\n") + + def test_log_print_concurrent(tmp_path): """lob_print is safe to call from multiple threads simultaneously.