Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #345

Merged
merged 6 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Changelog

## [Unreleased]
### Fixed
- Log line reference for Python 3.11, by @HardNorth
### Changed
- Client version updated on [5.4.0](https://github.com/reportportal/client-Python/releases/tag/5.4.0), by @HardNorth

## [5.2.0]
### Added
- `rp_launch_uuid_print` and `rp_launch_uuid_print_output` configuration parameters, by @HardNorth
### Removed
Expand Down
3 changes: 0 additions & 3 deletions pytest_reportportal/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ def pytest_sessionstart(session):

if is_control(config) and not config._reporter_config.rp_launch_id:
config.py_test_service.start_launch()
if config._reporter_config.rp_launch_uuid_print:
launch_id = config.py_test_service.rp.launch_id
print(f'Report Portal Launch UUID: {launch_id}', file=config._reporter_config.rp_launch_uuid_print_output)
if config.pluginmanager.hasplugin('xdist') \
or config.pluginmanager.hasplugin('pytest-parallel'):
if not wait_launch(session.config.py_test_service.rp):
Expand Down
13 changes: 12 additions & 1 deletion pytest_reportportal/rp_logging.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""RPLogger class for low-level logging in tests."""

import sys
import logging
import threading
from contextlib import contextmanager
Expand Down Expand Up @@ -108,7 +109,17 @@ def _log(self, *args, **kwargs):
if attachment is not None:
kwargs.setdefault('extra', {}).update(
{'attachment': attachment})
return original_func(self, *args, **kwargs)
# Python 3.11 start catches stack frames in wrappers,
# so add additional stack level skip to not show it
if sys.version_info >= (3, 11):
my_kwargs = kwargs.copy()
if 'stacklevel' in kwargs:
my_kwargs['stacklevel'] = my_kwargs['stacklevel'] + 1
else:
my_kwargs['stacklevel'] = 2
return original_func(self, *args, **my_kwargs)
else:
return original_func(self, *args, **kwargs)

return _log

Expand Down
4 changes: 3 additions & 1 deletion pytest_reportportal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,9 @@ def start(self) -> None:
retries=self._config.rp_api_retries,
verify_ssl=self._config.rp_verify_ssl,
launch_id=launch_id,
log_batch_payload_size=self._config.rp_log_batch_payload_size
log_batch_payload_size=self._config.rp_log_batch_payload_size,
launch_uuid_print=self._config.rp_launch_uuid_print,
print_output=self._config.rp_launch_uuid_print_output
)
if hasattr(self.rp, "get_project_settings"):
self.project_settings = self.rp.get_project_settings()
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dill>=0.3.6
pytest>=3.8.0
reportportal-client==5.3.5
reportportal-client==5.4.0
aenum>=3.1.0
requests>=2.27.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from setuptools import setup


__version__ = '5.2.0'
__version__ = '5.2.1'


def read_file(fname):
Expand Down
25 changes: 9 additions & 16 deletions tests/integration/test_config_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,7 @@ def test_rp_log_format(mock_client_init):
expect(mock_client.log.call_count == 1)
message = mock_client.log.call_args_list[0][0][1]
expect(len(message) > 0)
if sys.version_info < (3, 11):
expect(message == '(examples.test_rp_logging) ' + LOG_MESSAGE +
' (test_rp_logging.py:24)')
else:
# FIXME: implement stacktrace preserve solution for Python 3.11
warnings.warn('FIXME: implement stacktrace preserve solution for Python 3.11', RuntimeWarning)
expect(message == '(examples.test_rp_logging) ' + LOG_MESSAGE +
' (rp_logging.py:111)')
expect(message == f'(examples.test_rp_logging) {LOG_MESSAGE} (test_rp_logging.py:24)')
assert_expectations()


Expand Down Expand Up @@ -304,8 +297,8 @@ def test_launch_uuid_print(mock_client_init):

assert int(result) == 0, 'Exit code should be 0 (no errors)'
expect(mock_client_init.call_count == 1)

expect('Report Portal Launch UUID:' in str_io.getvalue())
expect(mock_client_init.call_args_list[0][1]['launch_uuid_print'] == print_uuid)
expect(mock_client_init.call_args_list[0][1]['print_output'] is str_io)
assert_expectations()


Expand All @@ -326,8 +319,8 @@ def test_launch_uuid_print_stderr(mock_client_init):

assert int(result) == 0, 'Exit code should be 0 (no errors)'
expect(mock_client_init.call_count == 1)

expect('Report Portal Launch UUID:' in str_io.getvalue())
expect(mock_client_init.call_args_list[0][1]['launch_uuid_print'] == print_uuid)
expect(mock_client_init.call_args_list[0][1]['print_output'] is str_io)
assert_expectations()


Expand All @@ -348,8 +341,8 @@ def test_launch_uuid_print_invalid_output(mock_client_init):

assert int(result) == 0, 'Exit code should be 0 (no errors)'
expect(mock_client_init.call_count == 1)

expect('Report Portal Launch UUID:' in str_io.getvalue())
expect(mock_client_init.call_args_list[0][1]['launch_uuid_print'] == print_uuid)
expect(mock_client_init.call_args_list[0][1]['print_output'] is str_io)
assert_expectations()


Expand All @@ -368,6 +361,6 @@ def test_no_launch_uuid_print(mock_client_init):

assert int(result) == 0, 'Exit code should be 0 (no errors)'
expect(mock_client_init.call_count == 1)

expect('Report Portal Launch UUID:' not in str_io.getvalue())
expect(mock_client_init.call_args_list[0][1]['launch_uuid_print'] is False)
expect(mock_client_init.call_args_list[0][1]['print_output'] is str_io)
assert_expectations()