Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 173420d

Browse filesBrowse files
committed
add flag that allows not to attach logs for passed tests
1 parent 61da8af commit 173420d
Copy full SHA for 173420d

File tree

3 files changed

+52
-0
lines changed
Filter options

3 files changed

+52
-0
lines changed

‎allure-pytest/src/listener.py

Copy file name to clipboardExpand all lines: allure-pytest/src/listener.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def pytest_runtest_makereport(self, item, call):
203203
test_result.statusDetails = status_details
204204

205205
if self.config.option.attach_capture:
206+
if test_result.status == Status.PASSED and not self.config.option.attach_capture_passed:
207+
return
208+
206209
if report.caplog:
207210
self.attach_data(report.caplog, "log", AttachmentType.TEXT, None)
208211
if report.capstdout:

‎allure-pytest/src/plugin.py

Copy file name to clipboardExpand all lines: allure-pytest/src/plugin.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ def pytest_addoption(parser):
3434
dest="attach_capture",
3535
help="Do not attach pytest captured logging/stdout/stderr to report")
3636

37+
parser.getgroup("reporting").addoption('--allure-no-capture-passed',
38+
action="store_false",
39+
dest="attach_capture_passed",
40+
help="Do not attach pytest captured logging/stdout/stderr to passed report")
41+
3742
def label_type(type_name, legal_values=set()):
3843
def a_label_type(string):
3944
atoms = set(string.split(','))

‎allure-pytest/test/acceptance/capture/capture_attach_test.py

Copy file name to clipboardExpand all lines: allure-pytest/test/acceptance/capture/capture_attach_test.py
+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,47 @@ def test_capture_disabled(allured_testdir):
124124
assert_that(allured_testdir.allure_report,
125125
has_property("attachments", empty())
126126
)
127+
128+
129+
def test_capture_passed_disabled_for_successful(allured_testdir):
130+
"""
131+
>>> import logging
132+
>>> logger = logging.getLogger(__name__)
133+
134+
>>> def test_capture_passed_disabled_example():
135+
... logger.info("Start logging")
136+
... print ("Start printing")
137+
138+
"""
139+
140+
allured_testdir.parse_docstring_source()
141+
allured_testdir.run_with_allure("--log-cli-level=INFO", "--allure-no-capture-passed")
142+
143+
assert_that(allured_testdir.allure_report,
144+
has_property("attachments", empty())
145+
)
146+
147+
148+
def test_capture_passed_disabled_for_unsuccessful(allured_testdir):
149+
"""
150+
>>> import logging
151+
>>> logger = logging.getLogger(__name__)
152+
153+
>>> def test_capture_passed_disabled_example():
154+
... logger.info("Start logging")
155+
... print ("Start printing")
156+
... assert False
157+
158+
"""
159+
160+
allured_testdir.parse_docstring_source()
161+
allured_testdir.run_with_allure("--log-cli-level=INFO", "--allure-no-capture-passed")
162+
163+
assert_that(allured_testdir.allure_report,
164+
has_property("attachments",
165+
all_of(
166+
is_(has_value(contains_string("Start logging"))),
167+
is_(has_value(contains_string("Start printing")))
168+
)
169+
)
170+
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.