diff --git a/CHANGELOG.md b/CHANGELOG.md index e9c924f..2fce5e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pytest_reportportal/plugin.py b/pytest_reportportal/plugin.py index 12446e5..9ff1a79 100644 --- a/pytest_reportportal/plugin.py +++ b/pytest_reportportal/plugin.py @@ -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): diff --git a/pytest_reportportal/rp_logging.py b/pytest_reportportal/rp_logging.py index 8655ee8..255ad2e 100644 --- a/pytest_reportportal/rp_logging.py +++ b/pytest_reportportal/rp_logging.py @@ -1,5 +1,6 @@ """RPLogger class for low-level logging in tests.""" +import sys import logging import threading from contextlib import contextmanager @@ -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 diff --git a/pytest_reportportal/service.py b/pytest_reportportal/service.py index 68a5f7e..e052a87 100644 --- a/pytest_reportportal/service.py +++ b/pytest_reportportal/service.py @@ -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() diff --git a/requirements.txt b/requirements.txt index 5727128..01013c8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index 6886f26..2843dd4 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup -__version__ = '5.2.0' +__version__ = '5.2.1' def read_file(fname): diff --git a/tests/integration/test_config_handling.py b/tests/integration/test_config_handling.py index 1c5fa1c..17eb4d3 100644 --- a/tests/integration/test_config_handling.py +++ b/tests/integration/test_config_handling.py @@ -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() @@ -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() @@ -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() @@ -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() @@ -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()