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

Commit 2dd06a1

Browse files
vubvub
authored andcommitted
Merge branch 'develop' of github.com:ethereum/pyethereum into develop
2 parents 1ee7f2c + 1b339f0 commit 2dd06a1

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ peers.json
2424
pyethereum/todo.txt
2525
pyethereum/monkeypatch.py
2626
.eggs
27+
.cache

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: 16 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
@@ -308,6 +308,17 @@ def test_logging_reconfigure():
308308
assert len(eth_vm_logger.handlers) == 0
309309

310310

311+
@pytest.mark.parametrize(
312+
('config', 'logger', 'level'), (
313+
(":WARNING", "", "WARNING"),
314+
(":DEBUG,eth:INFO", "", "DEBUG"),
315+
(":DEBUG,eth:INFO", "eth", "INFO"),
316+
(":DEBUG,eth:INFO,devp2p:INFO", "devp2p", "INFO"),))
317+
def test_logging_reconfigure_levels(config, logger, level):
318+
slogging.configure(config)
319+
assert slogging.getLogger(logger).level == getattr(logging, level)
320+
321+
311322
def test_set_level():
312323
slogging.set_level('test', 'CRITICAL')
313324
assert slogging.getLogger('test').level == logging.CRITICAL

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ envlist = py27,coverage
55
[testenv]
66
setenv =
77
PYTHONPATH = {toxinidir}:{toxinidir}/ethereum
8-
#commands = python setup.py test
98
commands = coverage run --source=ethereum --branch -m py.test {posargs}
109
deps =
1110
-r{toxinidir}/requirements.txt
@@ -15,5 +14,6 @@ deps =
1514
[testenv:coverage]
1615
deps =
1716
coverage
17+
skip_install = true
1818
commands =
1919
coverage report --show-missing

0 commit comments

Comments
 (0)