From 1bb4e316cab98e0722a06af6a9ede0fd47fd094f Mon Sep 17 00:00:00 2001 From: "reportportal.io" Date: Wed, 20 Mar 2024 13:27:28 +0000 Subject: [PATCH 1/8] Changelog update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17b7ad2..8928927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] + +## [5.5.6] ### Added - `CONTENT_TYPE_TO_EXTENSIONS` constant in `helpers` module, by @HardNorth ### Fixed From 2cada439caedfe2b3e823a78392e231c52bd0401 Mon Sep 17 00:00:00 2001 From: "reportportal.io" Date: Wed, 20 Mar 2024 13:27:29 +0000 Subject: [PATCH 2/8] Version update --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8540220..faa88a2 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages -__version__ = '5.5.6' +__version__ = '5.5.7' TYPE_STUBS = ['*.pyi'] From bd50b91f55f9d8dd9ea0dab649e207562ab3a843 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Tue, 30 Apr 2024 14:33:41 +0300 Subject: [PATCH 3/8] Action version update --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index decfabc..4ef14d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,7 @@ jobs: version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }} - name: Setup git credentials - uses: oleksiyrudenko/gha-git-credentials@v2.1.1 + uses: oleksiyrudenko/gha-git-credentials@v2-latest with: name: 'reportportal.io' email: 'support@reportportal.io' From 9a02f942013ca7fdef596c80153f3e6f46a5da21 Mon Sep 17 00:00:00 2001 From: Dagan Sandler <1357456+dagansandler@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:25:14 +0300 Subject: [PATCH 4/8] adding file location assertion to test_rp_logger, and fixing for 3.11 --- reportportal_client/logs/__init__.py | 2 ++ tests/logs/test_rp_logger.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/reportportal_client/logs/__init__.py b/reportportal_client/logs/__init__.py index c5c7a70..c699bdc 100644 --- a/reportportal_client/logs/__init__.py +++ b/reportportal_client/logs/__init__.py @@ -58,6 +58,8 @@ def _log(self, level, msg, args, exc_info=None, extra=None, # exception on some versions of IronPython. We trap it here so that # IronPython can use logging. try: + if sys.version_info >= (3, 11): + kwargs.setdefault('stacklevel', 2) if 'stacklevel' in kwargs: fn, lno, func, sinfo = \ self.findCaller(stack_info, kwargs['stacklevel']) diff --git a/tests/logs/test_rp_logger.py b/tests/logs/test_rp_logger.py index a6beefb..7ecaaa4 100644 --- a/tests/logs/test_rp_logger.py +++ b/tests/logs/test_rp_logger.py @@ -40,6 +40,7 @@ def test_record_make(logger_handler): logger.info('test_log') record = verify_record(logger_handler) assert not getattr(record, 'attachment') + assert record.pathname == __file__ @mock.patch('reportportal_client.logs.logging.Logger.handle') @@ -86,3 +87,4 @@ def test_stacklevel_record_make(logger_handler): stack_info=inspect.stack(), stacklevel=2) record = verify_record(logger_handler) assert record.stack_info.endswith("logger.error('test_log', exc_info=RuntimeError('test'),") + assert record.pathname == __file__ From 960cb9dc67342f4dcfeee22d0fc7dfb0d9e1e4f2 Mon Sep 17 00:00:00 2001 From: Jonas Lauer Date: Fri, 16 Aug 2024 16:57:58 +0200 Subject: [PATCH 5/8] Fix ssl context when certificate is provided --- reportportal_client/aio/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reportportal_client/aio/client.py b/reportportal_client/aio/client.py index c969460..126f1ec 100644 --- a/reportportal_client/aio/client.py +++ b/reportportal_client/aio/client.py @@ -161,9 +161,9 @@ async def session(self) -> RetryingClientSession: ssl_config = False else: if type(self.verify_ssl) is str: - ssl_config = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH, cafile=self.verify_ssl) + ssl_config = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=self.verify_ssl) else: - ssl_config = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH, cafile=certifi.where()) + ssl_config = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=certifi.where()) connection_params = { 'ssl': ssl_config, From ce737ffeaf7c27b7cd6d68328d54baeb6b5b3e07 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 4 Sep 2024 12:14:37 +0300 Subject: [PATCH 6/8] Add Python 3.12 to builders --- .github/workflows/tests.yml | 2 +- setup.py | 1 + tox.ini | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c283e61..3d2e061 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] + python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ] steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/setup.py b/setup.py index faa88a2..27b3e49 100644 --- a/setup.py +++ b/setup.py @@ -45,6 +45,7 @@ def read_file(fname): 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], install_requires=read_file('requirements.txt').splitlines(), ) diff --git a/tox.ini b/tox.ini index 2f8dad0..fbfbada 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ envlist = py39 py310 py311 + py312 [testenv] deps = @@ -30,3 +31,4 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 From 6ed02a205951263226d6f9033b2c65f227fa4fda Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 4 Sep 2024 12:14:59 +0300 Subject: [PATCH 7/8] Add helpers.to_bool function --- reportportal_client/helpers.py | 16 +++++++++++++++ tests/test_helpers.py | 36 ++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/reportportal_client/helpers.py b/reportportal_client/helpers.py index 122a978..d7eb95f 100644 --- a/reportportal_client/helpers.py +++ b/reportportal_client/helpers.py @@ -477,3 +477,19 @@ def guess_content_type_from_bytes(data: Union[bytes, bytearray, List[int]]) -> s return 'application/pdf' return 'application/octet-stream' + + +def to_bool(value: Optional[Any]) -> Optional[bool]: + """Convert value of any type to boolean or raise ValueError. + + :param value: value to convert + :return: boolean value + :raises ValueError: if value is not boolean + """ + if value is None: + return None + if value in {'TRUE', 'True', 'true', '1', 'Y', 'y', 1, True}: + return True + if value in {'FALSE', 'False', 'false', '0', 'N', 'n', 0, False}: + return False + raise ValueError(f'Invalid boolean value {value}.') diff --git a/tests/test_helpers.py b/tests/test_helpers.py index f4c47f2..b5800eb 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -19,8 +19,7 @@ import pytest from reportportal_client.helpers import ( - gen_attributes, - get_launch_sys_attrs, + gen_attributes, get_launch_sys_attrs, to_bool, verify_value_length, ATTRIBUTE_LENGTH_LIMIT, TRUNCATE_REPLACEMENT, guess_content_type_from_bytes, is_binary ) @@ -134,3 +133,36 @@ def test_binary_content_type_detection(file, expected_type): with open(file, 'rb') as f: content = f.read() assert guess_content_type_from_bytes(content) == expected_type + + +@pytest.mark.parametrize( + 'value, expected_result', + [ + ('TRUE', True), + ('True', True), + ('true', True), + ('Y', True), + ('y', True), + (True, True), + (1, True), + ('1', True), + ('FALSE', False), + ('False', False), + ('false', False), + ('N', False), + ('n', False), + (False, False), + (0, False), + ('0', False), + (None, None), + ] +) +def test_to_bool(value, expected_result): + """Test for validate to_bool() function.""" + assert to_bool(value) == expected_result + + +def test_to_bool_invalid_value(): + """Test for validate to_bool() function exception case.""" + with pytest.raises(ValueError): + to_bool('invalid_value') From 6401bae7f2baf2786782370604b3bf65b6a0fb4c Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 4 Sep 2024 12:30:46 +0300 Subject: [PATCH 8/8] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8928927..b7782cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog ## [Unreleased] +### Added +- `helpers.to_bool` function, by @HardNorth +- Official `Python 3.12` support, by @HardNorth +### Fixed +- SSL context when certificate is provided, by @JLBIZ +- Log Record pathnames are incorrect on python3.11, by @dagansandler ## [5.5.6] ### Added