Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Pytest 4 compatibility (#78)
Browse files Browse the repository at this point in the history
* Pytest 4 compatibility

* Update global version
  • Loading branch information
apallier authored and allankp committed Dec 5, 2018
1 parent 51e8fc8 commit 47bc4be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions pytest_testrail/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ def get_testrail_keys(items):
"""Return Tuple of Pytest nodes and TestRail ids from pytests markers"""
testcaseids = []
for item in items:
if item.get_marker(TESTRAIL_PREFIX):
if item.get_closest_marker(TESTRAIL_PREFIX):
testcaseids.append(
(
item,
clean_test_ids(
item.get_marker(TESTRAIL_PREFIX).kwargs.get('ids')
item.get_closest_marker(TESTRAIL_PREFIX).kwargs.get('ids')
)
)
)
Expand Down Expand Up @@ -182,13 +182,13 @@ def pytest_runtest_makereport(self, item, call):
""" Collect result and associated testcases (TestRail) of an execution """
outcome = yield
rep = outcome.get_result()
if item.get_marker(TESTRAIL_PREFIX):
testcaseids = item.get_marker(TESTRAIL_PREFIX).kwargs.get('ids')
if item.get_closest_marker(TESTRAIL_PREFIX):
testcaseids = item.get_closest_marker(TESTRAIL_PREFIX).kwargs.get('ids')

if rep.when == 'call' and testcaseids:
self.add_result(
clean_test_ids(testcaseids),
get_test_outcome(outcome.result.outcome),
get_test_outcome(outcome.get_result().outcome),
comment=rep.longrepr,
duration=rep.duration
)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def read_file(fname):
name='pytest-testrail',
description='pytest plugin for creating TestRail runs and adding results',
long_description=read_file('README.rst'),
version='2.3.1',
version='2.3.2',
author='Allan Kilpatrick',
author_email='[email protected]',
url='http://github.com/allankp/pytest-testrail/',
Expand All @@ -19,7 +19,7 @@ def read_file(fname):
],
package_dir={'pytest_testrail': 'pytest_testrail'},
install_requires=[
'pytest>=2',
'pytest>=3.6',
'requests>=2.20.0',
'simplejson',
],
Expand Down
8 changes: 4 additions & 4 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ def test_skip_missing_only_one_test(api_client, pytest_test_items):

my_plugin.pytest_collection_modifyitems(None, None, pytest_test_items)

assert not pytest_test_items[0].get_marker('skip')
assert pytest_test_items[1].get_marker('skip')
assert not pytest_test_items[0].get_closest_marker('skip')
assert pytest_test_items[1].get_closest_marker('skip')


def test_skip_missing_correlation_tests(api_client, pytest_test_items):
Expand All @@ -357,5 +357,5 @@ def test_skip_missing_correlation_tests(api_client, pytest_test_items):

my_plugin.pytest_collection_modifyitems(None, None, pytest_test_items)

assert not pytest_test_items[0].get_marker('skip')
assert not pytest_test_items[1].get_marker('skip')
assert not pytest_test_items[0].get_closest_marker('skip')
assert not pytest_test_items[1].get_closest_marker('skip')

0 comments on commit 47bc4be

Please sign in to comment.