Skip to content

Commit 51fe2ca

Browse files
authored
Merge pull request #361 from reportportal/develop
Release
2 parents e0eb90b + f7e20f9 commit 51fe2ca

File tree

12 files changed

+74
-59
lines changed

12 files changed

+74
-59
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
runs-on: ubuntu-latest
3737
steps:
3838
- name: Checkout repository
39-
uses: actions/checkout@v3
39+
uses: actions/checkout@v4
4040

4141
- name: Set up Python
42-
uses: actions/setup-python@v4
42+
uses: actions/setup-python@v5
4343
with:
4444
python-version: '3.8'
4545

@@ -76,7 +76,7 @@ jobs:
7676
git push --tags
7777
7878
- name: Checkout develop branch
79-
uses: actions/checkout@v3
79+
uses: actions/checkout@v4
8080
with:
8181
ref: 'develop'
8282
fetch-depth: 0

.github/workflows/tests.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
2424
steps:
2525
- name: Checkout repository
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727

2828
- name: Set up Python ${{ matrix.python-version }}
29-
uses: actions/setup-python@v4
29+
uses: actions/setup-python@v5
3030
with:
3131
python-version: ${{ matrix.python-version }}
3232

@@ -40,8 +40,9 @@ jobs:
4040

4141
- name: Upload coverage to Codecov
4242
if: matrix.python-version == 3.8 && success()
43-
uses: codecov/codecov-action@v3
43+
uses: codecov/codecov-action@v4
4444
with:
45+
token: ${{ secrets.CODECOV_TOKEN }}
4546
files: coverage.xml
4647
flags: unittests
4748
name: codecov-client-reportportal

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Added
5+
- Pytest version >= 8 support, by @HardNorth
6+
### Removed
7+
- `Packege` and `Dir` item types processing on test collection. This is done to preserve backward compatibility and improve name consistency, by @HardNorth
8+
### Changed
9+
- `rp_issue_system_url` renamed to `rp_bts_issue_url` to be consistent with other agents, by @HardNorth
10+
11+
## [5.3.2]
412
### Changed
513
- Set upper pytest version limit to not include `8.0.0`, by @HardNorth
614

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ agent-python-pytest
1414
.. image:: https://codecov.io/gh/reportportal/agent-python-pytest/branch/develop/graph/badge.svg
1515
:target: https://codecov.io/gh/reportportal/agent-python-pytest
1616
:alt: Test coverage
17-
.. image:: https://slack.epmrpp.reportportal.io/badge.svg
17+
.. image:: https://img.shields.io/badge/slack-join-brightgreen.svg
1818
:target: https://slack.epmrpp.reportportal.io/
1919
:alt: Join Slack chat!
2020

pytest_reportportal/config.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AgentConfig:
4444
rp_ignore_attributes: set
4545
rp_is_skipped_an_issue: bool
4646
rp_issue_id_marks: bool
47-
rp_issue_system_url: str
47+
rp_bts_issue_url: str
4848
rp_bts_project: str
4949
rp_bts_url: str
5050
rp_launch: str
@@ -88,8 +88,16 @@ def __init__(self, pytest_config: Config) -> None:
8888
)
8989
self.rp_issue_id_marks = self.find_option(pytest_config,
9090
'rp_issue_id_marks')
91-
self.rp_issue_system_url = self.find_option(pytest_config,
92-
'rp_issue_system_url')
91+
self.rp_bts_issue_url = self.find_option(pytest_config, 'rp_bts_issue_url')
92+
if not self.rp_bts_issue_url:
93+
self.rp_bts_issue_url = self.find_option(pytest_config, 'rp_issue_system_url')
94+
if self.rp_bts_issue_url:
95+
warnings.warn(
96+
'Parameter `rp_issue_system_url` is deprecated since 5.4.0 and will be subject for removing'
97+
'in the next major version. Use `rp_bts_issue_url` argument instead.',
98+
DeprecationWarning,
99+
2
100+
)
93101
self.rp_bts_project = self.find_option(pytest_config, 'rp_bts_project')
94102
self.rp_bts_url = self.find_option(pytest_config, 'rp_bts_url')
95103
self.rp_launch = self.find_option(pytest_config, 'rp_launch')

pytest_reportportal/plugin.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,13 @@ def add_shared_option(name, help_str, default=None, action='store'):
452452
parser.addini(
453453
'rp_issue_system_url',
454454
default='',
455-
help='URL to get issue description. Issue id '
456-
'from pytest mark will be added to this URL')
455+
help='URL to get issue description. Issue id from pytest mark will be added to this URL. '
456+
'Deprecated: use "rp_bts_issue_url".')
457+
parser.addini(
458+
'rp_bts_issue_url',
459+
default='',
460+
help='URL to get issue description. Issue ID from pytest mark will be added to this URL by replacing '
461+
'"{issue_id}" placeholder.')
457462
parser.addini(
458463
'rp_bts_project',
459464
default='',

pytest_reportportal/service.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
except ImportError:
3737
# in pytest >= 7.0 this type was removed
3838
Instance = type('dummy', (), {})
39+
try:
40+
from pytest import Dir
41+
except ImportError:
42+
# in pytest < 8.0 there is no such type
43+
Dir = type('dummy', (), {})
3944
from reportportal_client import RP, create_client
4045
from reportportal_client.helpers import (
4146
dict_to_payload,
@@ -233,7 +238,7 @@ def _get_tree_path(self, item):
233238
path = [item]
234239
parent = item.parent
235240
while parent is not None and not isinstance(parent, Session):
236-
if not isinstance(parent, Instance):
241+
if not isinstance(parent, Instance) and not isinstance(parent, Dir) and not isinstance(parent, Package):
237242
path.append(parent)
238243
parent = parent.parent
239244

@@ -282,22 +287,6 @@ def _build_test_tree(self, session):
282287
current_leaf = children_leafs[leaf]
283288
return test_tree
284289

285-
def _remove_root_package(self, test_tree):
286-
if test_tree['type'] == LeafType.ROOT or \
287-
test_tree['type'] == LeafType.DIR:
288-
for item, child_leaf in test_tree['children'].items():
289-
self._remove_root_package(child_leaf)
290-
return
291-
if test_tree['type'] == LeafType.CODE and \
292-
isinstance(test_tree['item'], Package) and \
293-
test_tree['parent']['type'] == LeafType.DIR:
294-
parent_leaf = test_tree['parent']
295-
current_item = test_tree['item']
296-
del parent_leaf['children'][current_item]
297-
for item, child_leaf in test_tree['children'].items():
298-
parent_leaf['children'][item] = child_leaf
299-
child_leaf['parent'] = parent_leaf
300-
301290
def _remove_root_dirs(self, test_tree, max_dir_level, dir_level=0):
302291
if test_tree['type'] == LeafType.ROOT:
303292
for item, child_leaf in test_tree['children'].items():
@@ -323,10 +312,7 @@ def _generate_names(self, test_tree):
323312

324313
if test_tree['type'] == LeafType.CODE:
325314
item = test_tree['item']
326-
if isinstance(item, Package):
327-
test_tree['name'] = \
328-
os.path.split(os.path.split(str(item.fspath))[0])[1]
329-
elif isinstance(item, Module):
315+
if isinstance(item, Module):
330316
test_tree['name'] = os.path.split(str(item.fspath))[1]
331317
else:
332318
test_tree['name'] = item.name
@@ -376,7 +362,6 @@ def collect_tests(self, session):
376362
"""
377363
# Create a test tree to be able to apply mutations
378364
test_tree = self._build_test_tree(session)
379-
self._remove_root_package(test_tree)
380365
self._remove_root_dirs(test_tree, self._config.rp_dir_level)
381366
self._generate_names(test_tree)
382367
if not self._config.rp_hierarchy_dirs:
@@ -554,7 +539,7 @@ def _get_issue(self, mark):
554539
:param mark: pytest mark
555540
:return: Issue object
556541
"""
557-
default_url = self._config.rp_issue_system_url
542+
default_url = self._config.rp_bts_issue_url
558543

559544
issue_description_line = \
560545
self._get_issue_description_line(mark, default_url)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dill>=0.3.6
2-
pytest>=3.8.0,<8.0.0
2+
pytest>=3.8.0
33
reportportal-client~=5.5.4
44
aenum>=3.1.0
55
requests>=2.28.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from setuptools import setup
1919

2020

21-
__version__ = '5.3.2'
21+
__version__ = '5.4.0'
2222

2323

2424
def read_file(fname):

tests/integration/test_config_handling.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,21 @@ def test_retries(mock_client_init):
258258
assert_expectations()
259259

260260

261+
@mock.patch(REPORT_PORTAL_SERVICE)
262+
def test_rp_issue_system_url_warning(mock_client_init):
263+
url = 'https://bugzilla.some.com/show_bug.cgi?id={issue_id}'
264+
variables = utils.DEFAULT_VARIABLES.copy()
265+
variables.update({'rp_issue_system_url': str(url)}.items())
266+
267+
with warnings.catch_warnings(record=True) as w:
268+
result = utils.run_pytest_tests(['examples/test_issue_id.py'], variables=variables)
269+
assert int(result) == 1, 'Exit code should be 1 (test failure)'
270+
271+
expect(mock_client_init.call_count == 1)
272+
expect(len(filter_agent_calls(w)) == 1)
273+
assert_expectations()
274+
275+
261276
@mock.patch(REPORT_PORTAL_SERVICE)
262277
def test_launch_uuid_print(mock_client_init):
263278
print_uuid = True

0 commit comments

Comments
 (0)