Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
eisensheng committed Dec 7, 2014
1 parent 485c223 commit 948bfcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ stderr.

Running without options::

py.test test_catchlog.py
py.test test_pytest_catchlog.py

Shows failed tests like so::

Expand Down Expand Up @@ -56,7 +56,7 @@ Shows failed tests like so::

Further it is possible to disable capturing of logs completely with::

py.test --nocatchlog test_catchlog.py
py.test --nocatchlog test_pytest_catchlog.py

Shows failed tests in the normal manner as no logs were captured:

Expand Down
16 changes: 8 additions & 8 deletions test_pytest_catchlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def test_foo():
''')
result = testdir.runpytest()
assert result.ret == 1
result.stdout.fnmatch_lines(['*- Captured stdout -*',
result.stdout.fnmatch_lines(['*- Captured stdout call -*',
'text going to stdout'])
result.stdout.fnmatch_lines(['*- Captured stderr -*',
result.stdout.fnmatch_lines(['*- Captured stderr call -*',
'text going to stderr'])
py.test.raises(Exception, result.stdout.fnmatch_lines,
['*- Captured log -*'])
Expand All @@ -42,9 +42,9 @@ def test_foo():
assert result.ret == 1
result.stdout.fnmatch_lines(['*- Captured log -*',
'*text going to logger*'])
result.stdout.fnmatch_lines(['*- Captured stdout -*',
result.stdout.fnmatch_lines(['*- Captured stdout call -*',
'text going to stdout'])
result.stdout.fnmatch_lines(['*- Captured stderr -*',
result.stdout.fnmatch_lines(['*- Captured stderr call -*',
'text going to stderr'])


Expand All @@ -56,12 +56,12 @@ def test_change_level(testdir):
pytest_plugins = 'catchlog'
def test_foo(caplog):
caplog.setLevel(logging.INFO)
caplog.set_level(logging.INFO)
log = logging.getLogger()
log.debug('handler DEBUG level')
log.info('handler INFO level')
caplog.setLevel(logging.CRITICAL, logger='root.baz')
caplog.set_level(logging.CRITICAL, logger='root.baz')
log = logging.getLogger('root.baz')
log.warning('logger WARNING level')
log.critical('logger CRITICAL level')
Expand Down Expand Up @@ -89,12 +89,12 @@ def test_with_statement(testdir):
pytest_plugins = 'catchlog'
def test_foo(caplog):
with caplog.atLevel(logging.INFO):
with caplog.at_level(logging.INFO):
log = logging.getLogger()
log.debug('handler DEBUG level')
log.info('handler INFO level')
with caplog.atLevel(logging.CRITICAL, logger='root.baz'):
with caplog.at_level(logging.CRITICAL, logger='root.baz'):
log = logging.getLogger('root.baz')
log.warning('logger WARNING level')
log.critical('logger CRITICAL level')
Expand Down

0 comments on commit 948bfcf

Please sign in to comment.