Skip to content

Commit ac16abc

Browse files
committed
test: assert logging output
1 parent 324ad37 commit ac16abc

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

python/tests/unit/common/test_logging.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,31 @@
22
import pytest
33

44

5-
def test_basics():
5+
def test_basics(capsys):
66
dart.common.trace("trace log")
77
dart.common.debug("debug log")
88
dart.common.info("info log")
99
dart.common.warn("warn log")
1010
dart.common.error("error log")
1111
dart.common.fatal("fatal log")
1212

13+
captured = capsys.readouterr()
14+
combined = captured.out + captured.err
1315

14-
def test_arguments():
16+
assert "trace log" in combined
17+
assert "debug log" in combined
18+
assert "info log" in combined
19+
assert "warn log" in combined
20+
assert "error log" in combined
21+
assert "fatal log" in combined
22+
23+
24+
def test_arguments(capsys):
1525
val = 10
1626
dart.common.info("Log with param '{}' and '{}'".format(1, val))
27+
captured = capsys.readouterr()
28+
combined = captured.out + captured.err
29+
assert "Log with param '1' and '10'" in combined
1730

1831

1932
if __name__ == "__main__":

0 commit comments

Comments
 (0)