Skip to content

Commit 595aeeb

Browse files
committed
test: assert logging output
1 parent 2fe24e2 commit 595aeeb

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

python/tests/unit/common/test_logging.py

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

44

5-
def test_basics():
5+
def assert_logged(capsys, expected):
6+
captured = capsys.readouterr()
7+
assert expected in captured.out or expected in captured.err
8+
9+
10+
def test_basics(capsys):
611
dart.common.trace("trace log")
12+
assert_logged(capsys, "trace log")
13+
714
dart.common.debug("debug log")
15+
assert_logged(capsys, "debug log")
16+
817
dart.common.info("info log")
18+
assert_logged(capsys, "info log")
19+
920
dart.common.warn("warn log")
21+
assert_logged(capsys, "warn log")
22+
1023
dart.common.error("error log")
24+
assert_logged(capsys, "error log")
25+
1126
dart.common.fatal("fatal log")
27+
assert_logged(capsys, "fatal log")
1228

1329

14-
def test_arguments():
30+
def test_arguments(capsys):
1531
val = 10
1632
dart.common.info("Log with param '{}' and '{}'".format(1, val))
33+
assert_logged(capsys, "Log with param '1' and '10'")
1734

1835

1936
if __name__ == "__main__":

0 commit comments

Comments
 (0)