Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 49bb6af

Browse files
committed
Switch to pytest-catchlog
Fixes: #291
1 parent d6a81d4 commit 49bb6af

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
tox
22
coveralls
33
pytest
4-
pytest-capturelog
4+
pytest-catchlog==1.1
55
pytest-timeout
66
https://github.com/ethereum/serpent/tarball/develop

ethereum/tests/conftest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
from ethereum import slogging
33

44

5+
CATCH_LOG_HANDLER_NAME = 'catch_log_handler'
6+
7+
58
@pytest.mark.hookwrapper
69
def pytest_runtest_setup(item):
7-
"""Attach pytest-capturelog's handler to `slogging`'s root logger"""
10+
"""Attach pytest-catchlog's handler to `slogging`'s root logger"""
811
yield
9-
caplog_handler = getattr(item, 'capturelog_handler', None)
12+
caplog_handler = getattr(item, CATCH_LOG_HANDLER_NAME, None)
1013
if caplog_handler and caplog_handler not in slogging.rootLogger.handlers:
1114
slogging.rootLogger.addHandler(caplog_handler)
1215

1316

1417
@pytest.mark.hookwrapper
1518
def pytest_runtest_makereport(item, call):
16-
"""Remove pytest-capturelog's handler from `slogging`'s root logger"""
19+
"""Remove pytest-catchlog's handler from `slogging`'s root logger"""
1720
if call.when == 'call':
18-
caplog_handler = getattr(item, 'capturelog_handler', None)
21+
caplog_handler = getattr(item, CATCH_LOG_HANDLER_NAME, None)
1922
if caplog_handler and caplog_handler in slogging.rootLogger.handlers:
2023
slogging.rootLogger.removeHandler(caplog_handler)
2124
yield

ethereum/tests/test_logging.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
def test_basic(caplog, level_name):
1010
slogging.configure(":trace")
1111
log = slogging.get_logger()
12-
with caplog.atLevel('TRACE'):
12+
with caplog.at_level('TRACE'):
1313
getattr(log, level_name)(level_name)
1414

1515
assert len(caplog.records()) == 1
@@ -234,13 +234,13 @@ def test_bound_logger(caplog):
234234
real_log = slogging.getLogger()
235235

236236
bound_log_1 = real_log.bind(key1="value1")
237-
with caplog.atLevel(slogging.TRACE):
237+
with caplog.at_level(slogging.TRACE):
238238
bound_log_1.info("test1")
239239
assert "test1" in caplog.text()
240240
assert "key1=value1" in caplog.text()
241241

242242
bound_log_2 = bound_log_1.bind(key2="value2")
243-
with caplog.atLevel(slogging.TRACE):
243+
with caplog.at_level(slogging.TRACE):
244244
bound_log_2.info("test2")
245245
assert "test2" in caplog.text()
246246
assert "key1=value1" in caplog.text()
@@ -255,14 +255,14 @@ def test_bound_logger_isolation(caplog):
255255
real_log = slogging.getLogger()
256256

257257
bound_log_1 = real_log.bind(key1="value1")
258-
with caplog.atLevel(slogging.TRACE):
258+
with caplog.at_level(slogging.TRACE):
259259
bound_log_1.info("test1")
260260
records = caplog.records()
261261
assert len(records) == 1
262262
assert "test1" in records[0].msg
263263
assert "key1=value1" in records[0].msg
264264

265-
with caplog.atLevel(slogging.TRACE):
265+
with caplog.at_level(slogging.TRACE):
266266
real_log.info("test2")
267267
records = caplog.records()
268268
assert len(records) == 2

0 commit comments

Comments
 (0)