Records each call as an Entry; writes nothing.
@testing.effect tests run with a fresh one, so they read what they
(and the console loggers) wrote with testing.log_lines::
@testing.effect
def test_greets():
yield from console.log("hello")
assert (yield from testing.log_lines) == ["hello"]Attributes#
| Attribute | Type | Description |
|---|---|---|
entries | list[Entry] | Every call so far, in order. |
log_lines | Effect[list[object]] | Every argument given to |
error_lines | Effect[list[object]] | Every argument given to |
Functions#
__init__#
__init__() -> Nonedef __init__(self) -> None:
self._entries: list[Entry] = []layer#
layer() -> Layer[Never]Provide a fresh TestConsole as the CurrentConsole.
Returns Layer[Never]
@staticmethod
def layer() -> Layer[Never]:
"""Provide a fresh ``TestConsole`` as the ``CurrentConsole``."""
return layer_sync(CurrentConsole, TestConsole)assert_#
assert_(condition, *args) -> None| Parameter | Type | Description |
|---|---|---|
condition | bool | |
args | object = () |
def assert_(self, condition: bool, *args: object) -> None:
self._record("assert", condition, *args)clear#
clear() -> Nonedef clear(self) -> None:
self._record("clear")count#
count(label='default') -> None| Parameter | Type | Description |
|---|---|---|
label | str = 'default' |
def count(self, label: str = "default") -> None:
self._record("count", label)count_reset#
count_reset(label='default') -> None| Parameter | Type | Description |
|---|---|---|
label | str = 'default' |
def count_reset(self, label: str = "default") -> None:
self._record("count_reset", label)debug#
debug(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def debug(self, *args: object) -> None:
self._record("debug", *args)dir#
dir(item) -> None| Parameter | Type | Description |
|---|---|---|
item | object |
def dir(self, item: object) -> None:
self._record("dir", item)error#
error(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def error(self, *args: object) -> None:
self._record("error", *args)group#
group(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def group(self, *args: object) -> None:
self._record("group", *args)group_collapsed#
group_collapsed(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def group_collapsed(self, *args: object) -> None:
self._record("group_collapsed", *args)group_end#
group_end() -> Nonedef group_end(self) -> None:
self._record("group_end")info#
info(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def info(self, *args: object) -> None:
self._record("info", *args)log#
log(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def log(self, *args: object) -> None:
self._record("log", *args)table#
table(data, properties=None) -> None| Parameter | Type | Description |
|---|---|---|
data | object | |
properties | Sequence[str] | None = None |
def table(self, data: object, properties: Sequence[str] | None = None) -> None:
self._record("table", data, properties)time#
time(label='default') -> None| Parameter | Type | Description |
|---|---|---|
label | str = 'default' |
def time(self, label: str = "default") -> None:
self._record("time", label)time_end#
time_end(label='default') -> None| Parameter | Type | Description |
|---|---|---|
label | str = 'default' |
def time_end(self, label: str = "default") -> None:
self._record("time_end", label)time_log#
time_log(label='default', *args) -> None| Parameter | Type | Description |
|---|---|---|
label | str = 'default' | |
args | object = () |
def time_log(self, label: str = "default", *args: object) -> None:
self._record("time_log", label, *args)trace#
trace(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def trace(self, *args: object) -> None:
self._record("trace", *args)warn#
warn(*args) -> None| Parameter | Type | Description |
|---|---|---|
args | object = () |
def warn(self, *args: object) -> None:
self._record("warn", *args)