-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to set report section #39
Add option to set report section #39
Conversation
it may be helpful when you want to merge logs with stdout/err. or when you need to rename reporting section in general.
I'm not sure there's a way to merge logs with stdout/stderr without a LogHandler redirecting logs to the appropriate stream. I like the idea in general though. Could you make a test that (1) writes to stdout, then (2) logs, and then (3) writes to stdout once again. The reported output should appear interleaved, i.e. 1-2-3. I suspect it will show 1-3 in the first report section (stdout), and then 2 in the second separate section (logs, that just happens to be also named |
Yep, it seems I was right, here's what I get:
diff: diff --git a/test_pytest_catchlog.py b/test_pytest_catchlog.py
index 554988f..ed7c4da 100644
--- a/test_pytest_catchlog.py
+++ b/test_pytest_catchlog.py
@@ -340,15 +340,17 @@ def test_change_report_section(testdir):
import logging
def test_foo(caplog):
- sys.stdout.write('text going to stdout')
- logging.getLogger().info('log message going to stdout section')
+ sys.stdout.write('text going to stdout (1)\\n')
+ logging.getLogger().info('log message going to stdout section (2)')
+ sys.stdout.write('text going to stdout (3)\\n')
assert False
''')
result = testdir.runpytest()
print(result.stdout)
assert result.ret == 1
result.stdout.fnmatch_lines(['*- Captured stdout call -*',
- 'text going to stdout',
- '*log message going to stdout section'])
+ 'text going to stdout (1)\\n',
+ '*log message going to stdout section (2)',
+ 'text going to stdout (3)\\n'])
py.test.raises(Exception, result.stdout.fnmatch_lines,
['*- Captured *log call -*']) |
@abusalimov Yes, I am aware about that. Probably using 'merge' word wasn't good choice. I can describe what problem I was trying to solve. my problem is that pytest-junitxml plugin doesn't include 'log' section captured by this plugin into xml. I was considering 3 ways how to make them visible in jenkins report.
this patch is the implementation of option 2). |
since it was merged to pytest core, it is not relevant. closing ... |
it may be helpful when you want to merge logs with stdout/err.
or when you need to rename reporting section in general.