Skip to content

Commit ba6a4b6

Browse files
authored
Test description from docstring (fixes #106 via #113)
* test description from docstring * files
1 parent deac9ae commit ba6a4b6

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

allure-pytest/src/listener.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def pytest_runtest_protocol(self, item, nextitem):
6767
test_case = TestResult(name=item.name, uuid=uuid)
6868
self.allure_logger.schedule_test(uuid, test_case)
6969

70+
if hasattr(item, 'function'):
71+
test_case.description = item.function.__doc__
72+
7073
yield
7174

7275
test_case.labels += [Label(name, value) for name, value in allure_labels(item)]

allure-pytest/test/description/__init__.py

Whitespace-only changes.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
>>> allure_report = getfixture('allure_report')
4+
"""
5+
6+
7+
def test_text_description():
8+
"""
9+
>>> allure_report = getfixture('allure_report')
10+
>>> assert_that(allure_report,
11+
... has_test_case('test_text_description',
12+
... has_description(
13+
... starts_with('\\n >>> allure_report = ')
14+
... )
15+
... )
16+
... )
17+
"""
18+
pass
19+
20+
21+
def test_utf8_text_description():
22+
u"""
23+
>>> # рекурсия
24+
>>> allure_report = getfixture('allure_report')
25+
>>> assert_that(allure_report,
26+
... has_test_case('test_utf8_text_description',
27+
... has_description(
28+
... starts_with(u'\\n >>> # рекурсия')
29+
... )
30+
... )
31+
... )
32+
"""
33+
pass

allure-python-commons-test/src/result.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,7 @@ def with_status_message(message):
134134

135135
def has_history_id():
136136
return has_entry('historyId', anything())
137+
138+
139+
def has_description(*matchers):
140+
return has_entry('description', all_of(*matchers))

0 commit comments

Comments
 (0)