Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
etianen committed Feb 4, 2024
1 parent 4f4b18a commit 06c06a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
23 changes: 1 addition & 22 deletions tests/test_logot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from logot import Captured, Logot, logged
from tests import capture_soon, lines, logger
from tests import lines, logger


def test_capturing() -> None:
Expand Down Expand Up @@ -59,27 +59,6 @@ def test_assert_not_logged_fail(logot: Logot) -> None:
)


def test_wait_for_pass_immediate(logot: Logot) -> None:
logot.capture(Captured("INFO", "foo bar"))
logot.wait_for(logged.info("foo bar"))


def test_wait_for_pass_soon(logot: Logot) -> None:
with capture_soon(logot, Captured("INFO", "foo bar")):
logot.wait_for(logged.info("foo bar"))


def test_wait_for_fail(logot: Logot) -> None:
logot.capture(Captured("INFO", "boom!"))
with pytest.raises(AssertionError) as ex:
logot.wait_for(logged.info("foo bar"), timeout=0.1)
assert str(ex.value) == lines(
"Not logged:",
"",
"[INFO] foo bar",
)


def test_clear(logot: Logot) -> None:
logot.capture(Captured("INFO", "foo bar"))
logot.clear()
Expand Down
27 changes: 27 additions & 0 deletions tests/test_wait.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from __future__ import annotations

import pytest

from logot import Captured, Logot, logged
from tests import capture_soon, lines


def test_wait_for_pass_immediate(logot: Logot) -> None:
logot.capture(Captured("INFO", "foo bar"))
logot.wait_for(logged.info("foo bar"))


def test_wait_for_pass_soon(logot: Logot) -> None:
with capture_soon(logot, Captured("INFO", "foo bar")):
logot.wait_for(logged.info("foo bar"))


def test_wait_for_fail(logot: Logot) -> None:
logot.capture(Captured("INFO", "boom!"))
with pytest.raises(AssertionError) as ex:
logot.wait_for(logged.info("foo bar"), timeout=0.1)
assert str(ex.value) == lines(
"Not logged:",
"",
"[INFO] foo bar",
)

0 comments on commit 06c06a2

Please sign in to comment.