Skip to content

Commit

Permalink
Use @pytest.fixture for 'caplog', improve funcarg description
Browse files Browse the repository at this point in the history
  • Loading branch information
abusalimov committed Oct 1, 2015
1 parent 3954634 commit bec9098
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions pytest_catchlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging

import pytest
import py


Expand Down Expand Up @@ -207,13 +208,16 @@ def __exit__(self, exc_type, exc_value, traceback):
self.obj.setLevel(self.orig_level)


def pytest_funcarg__caplog(request):
"""Returns a funcarg to access and control log capturing."""
@pytest.fixture
def caplog(request):
"""Access and control log capturing.
return CatchLogFuncArg(request._pyfuncitem.catch_log_handler)


def pytest_funcarg__capturelog(request):
"""Returns a funcarg to access and control log capturing."""
Captured logs are available through the following methods::
* caplog.text() -> string containing formatted log output
* caplog.records() -> list of logging.LogRecord instances
* caplog.record_tuples() -> list of (logger_name, level, message) tuples
"""
return CatchLogFuncArg(request._pyfuncitem.catch_log_handler)

capturelog = caplog

0 comments on commit bec9098

Please sign in to comment.