Commit 22609c21 authored by Vadim Mazaev's avatar Vadim Mazaev

another tail tests fix

parent 76d242b3
......@@ -50,9 +50,12 @@ def test_tail(case: Case, tmp_path: Path) -> None:
output = io.BytesIO()
tail(test_file, lines_amount=case.lines, output=output)
answer = output.getvalue().decode().split(os.linesep)[:-1]
answer = output.getvalue().decode().split(os.linesep)
assert case.result == answer
assert answer[-1] == ''
lines = answer[:-1]
assert case.result == lines
def test_real_log_file() -> None:
......@@ -60,10 +63,13 @@ def test_real_log_file() -> None:
output = io.BytesIO()
tail(log_file, lines_amount=100, output=output)
answer = output.getvalue().decode().split(os.linesep)[:-1]
answer = output.getvalue().decode().split(os.linesep)
assert answer[-1] == ''
lines = answer[:-1]
ips = Counter(line.split()[3] for line in answer)
handles = Counter(line.split()[5] for line in answer)
ips = Counter(line.split()[3] for line in lines)
handles = Counter(line.split()[5] for line in lines)
assert dict(handles) == {
'/': 50,
......@@ -86,7 +92,10 @@ def test_stdout_by_default(capsys: CaptureFixture) -> None:
last_line = '[28/Sep/2019:15:57:03 +0000] py.manytask.org 91.228.178.70 "GET / HTTP/1.1" 200 0.130 8337 "0.128"'
tail(log_file, lines_amount=10)
answer = capsys.readouterr().out.split(os.linesep)[:-1]
answer = capsys.readouterr().out.split(os.linesep)
assert answer[-1] == ''
lines = answer[:-1]
assert len(answer) == 10
assert answer[-1] == last_line
assert len(lines) == 10
assert lines[-1] == last_line
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment