Skip to content

Commit adde220

Browse files
authored
add historyId (fixes #48 via #53)
* add placeholders in step's title feature * . * fix comment in tox.ini * add historyId
1 parent 0ff5619 commit adde220

File tree

7 files changed

+39
-1
lines changed

7 files changed

+39
-1
lines changed

allure-pytest/src/allure/listener.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
from allure_commons.utils import now
4+
from allure_commons.utils import md5
45
from allure_commons.utils import uuid4
56
from allure_commons.logger import AllureLogger
67
from allure_commons.model2 import TestStepResult, TestResult, TestBeforeResult, TestAfterResult
@@ -67,6 +68,7 @@ def pytest_runtest_protocol(self, item, nextitem):
6768
test_case.labels = [Label(name, value) for name, value in allure_labels(item)]
6869
test_case.links = [Link(link_type, url, name) for link_type, url, name in allure_links(item)]
6970
test_case.fullName = allure_full_name(item.nodeid)
71+
test_case.historyId = md5(test_case.fullName)
7072
test_case.labels.append(Label('package', allure_package(item.nodeid)))
7173

7274
uuid = self._cache.pop(item.nodeid)

allure-pytest/test/history/__init__.py

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""
2+
>>> allure_report = getfixture('allure_report')
3+
4+
>>> assert_that(allure_report,
5+
... all_of(
6+
... has_property('test_cases', has_length(6)),
7+
... has_property('test_groups', has_length(0))
8+
... )) # doctest: +SKIP
9+
"""
10+
11+
import pytest
12+
13+
14+
def test_history_id():
15+
"""
16+
>>> allure_report = getfixture('allure_report')
17+
>>> assert_that(allure_report,
18+
... has_test_case('test_history_id',
19+
... has_history_id()
20+
... )
21+
... )
22+
"""
23+
pytest.exit("Just test")

allure-pytest/test/matchers/item.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,6 @@ def has_status_details(*matchers):
131131
def with_status_message(message):
132132
return has_entry('message', message)
133133

134+
135+
def has_history_id():
136+
return has_entry('historyId', anything())

allure-python-commons/src/model2.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class ExecutableItem(object):
5959
@attrs
6060
class TestResult(ExecutableItem):
6161
uuid = attrib(default=None)
62+
historyId = attrib(default=None)
6263
fullName = attrib(default=None)
6364
labels = attrib(default=Factory(list))
6465
links = attrib(default=Factory(list))

allure-python-commons/src/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import time
22
import uuid
3+
import hashlib
4+
5+
6+
def md5(case_name):
7+
case_name = case_name.encode('utf-8')
8+
m = hashlib.md5()
9+
m.update(case_name)
10+
return m.hexdigest()
311

412

513
def uuid4():

allure-python-commons/tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tox]
22
envlist=
3-
py27,py33,py34,py35,static_check
3+
py{27,33,34,35}
4+
static_check
45

56

67
[testenv]

0 commit comments

Comments
 (0)