Skip to content

Commit 0415bf4

Browse files
author
Dzmitry Humianiuk
authored
Merge pull request #86 from rplevka/unittest_fix
add support for python unittest hierarchy
2 parents 4c6c0fb + cf626d8 commit 0415bf4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pytest_reportportal/service.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from _pytest.python import Class, Function, Instance, Module
1313
from _pytest.doctest import DoctestItem
1414
from _pytest.nodes import File, Item
15+
from _pytest.unittest import TestCaseFunction, UnitTestCase
1516
from reportportal_client import ReportPortalServiceAsync
1617

1718
log = logging.getLogger(__name__)
@@ -157,13 +158,18 @@ def collect_tests(self, session):
157158
item_parts = self._get_item_parts(item)
158159
rp_name = self._add_item_hier_parts_other(item_parts, item, Module, hier_module, parts, rp_name)
159160
rp_name = self._add_item_hier_parts_other(item_parts, item, Class, hier_class, parts, rp_name)
161+
# Hierarchy for unittest TestCase (class)
162+
rp_name = self._add_item_hier_parts_other(item_parts, item, UnitTestCase, hier_class, parts, rp_name)
163+
160164

161165
# Hierarchy for parametrized tests
162166
if hier_param:
163167
rp_name = self._add_item_hier_parts_parametrize(item, parts, tests_parts, rp_name)
164168

165169
# Hierarchy for test itself
166170
self._add_item_hier_parts_other(item_parts, item, Function, True, parts, rp_name)
171+
# Hierarchy for unittest TestCaseFunction (test)
172+
self._add_item_hier_parts_other(item_parts, item, TestCaseFunction, True, parts, rp_name)
167173

168174
# Result initialization
169175
for part in parts:
@@ -363,7 +369,7 @@ def _add_item_hier_parts_other(item_parts, item, item_type, hier_flag, report_pa
363369
if item_type is Module:
364370
module_path = str(item.fspath.new(dirname=rp_name, basename=part.fspath.basename, drive=""))
365371
rp_name = module_path if rp_name else module_path[1:]
366-
elif item_type in (Class, Function):
372+
elif item_type in (Class, Function, UnitTestCase, TestCaseFunction):
367373
rp_name += ("::" if rp_name else "") + part.name
368374

369375
if hier_flag:

0 commit comments

Comments
 (0)