Skip to content

Commit

Permalink
Construct Item object using from_parent for Pytest >= 6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nfk authored Feb 15, 2021
1 parent 68d8392 commit 41d0296
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pytest_reportportal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,14 @@ def _add_item_hier_parts_dirs(item, hier_flag, dirs_level, report_parts,
item_dir = dirs_parts[path]
rp_name = ""
else:
item_dir = File(dir_path, nodeid=dir_name,
session=item.session,
config=item.session.config)
if hasattr(Item, "from_parent"):
item_dir = File.from_parent(parent=item,
fspath=dir_path,
nodeid=dir_name)
else:
item_dir = File(dir_path, nodeid=dir_name,
session=item.session,
config=item.session.config)
rp_name += dir_name
item_dir._rp_name = rp_name
dirs_parts[path] = item_dir
Expand Down Expand Up @@ -514,9 +519,14 @@ def _add_item_hier_parts_parametrize(item, report_parts, tests_parts,
if test_fullname in tests_parts:
item_test = tests_parts[test_fullname]
else:
item_test = Item(test_fullname, nodeid=test_fullname,
session=item.session,
config=item.session.config)
if hasattr(Item, "from_parent"):
item_test = Item.from_parent(parent=item,
name=test_fullname,
nodeid=test_fullname)
else:
item_test = Item(test_fullname, nodeid=test_fullname,
session=item.session,
config=item.session.config)
item_test._rp_name = rp_name
item_test.obj = item.obj
item_test.keywords = item.keywords
Expand Down

0 comments on commit 41d0296

Please sign in to comment.