Merge 997e4fef76 into 37ac9ff44f
This commit is contained in:
commit
95d93e7ed8
|
|
@ -64,7 +64,7 @@ class LogInterceptor(io.TextIOWrapper):
|
|||
|
||||
# Simple handling for cr to overwrite the last output if it isnt a full line
|
||||
# else logs just get full of progress messages
|
||||
if isinstance(data, str) and data.startswith("\r") and not logs[-1]["m"].endswith("\n"):
|
||||
if isinstance(data, str) and data.startswith("\r") and logs and not logs[-1]["m"].endswith("\n"):
|
||||
logs.pop()
|
||||
logs.append(entry)
|
||||
super().write(data)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
from collections import deque
|
||||
import io
|
||||
|
||||
import app.logger
|
||||
|
||||
|
||||
def test_carriage_return_can_be_first_log_entry(monkeypatch):
|
||||
monkeypatch.setattr(app.logger, "logs", deque())
|
||||
stream = io.TextIOWrapper(io.BytesIO(), encoding="utf-8")
|
||||
interceptor = app.logger.LogInterceptor(stream)
|
||||
|
||||
interceptor.write("\rprogress")
|
||||
|
||||
assert len(app.logger.logs) == 1
|
||||
assert app.logger.logs[0]["m"] == "\rprogress"
|
||||
Loading…
Reference in New Issue