Skip to content

Commit 409f3a6

Browse files
authored
Merge pull request #236 from reportportal/develop
Release
2 parents e861d74 + 6401bae commit 409f3a6

File tree

10 files changed

+70
-7
lines changed

10 files changed

+70
-7
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
version-file-extraction-pattern: ${{ env.VERSION_EXTRACT_PATTERN }}
6464

6565
- name: Setup git credentials
66-
uses: oleksiyrudenko/gha-git-credentials@v2.1.1
66+
uses: oleksiyrudenko/gha-git-credentials@v2-latest
6767
with:
6868
name: 'reportportal.io'
6969

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
runs-on: ubuntu-latest
3535
strategy:
3636
matrix:
37-
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
37+
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12' ]
3838
steps:
3939
- name: Checkout repository
4040
uses: actions/checkout@v4

CHANGELOG.md

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

33
## [Unreleased]
44
### Added
5+
- `helpers.to_bool` function, by @HardNorth
6+
- Official `Python 3.12` support, by @HardNorth
7+
### Fixed
8+
- SSL context when certificate is provided, by @JLBIZ
9+
- Log Record pathnames are incorrect on python3.11, by @dagansandler
10+
11+
## [5.5.6]
12+
### Added
513
- `CONTENT_TYPE_TO_EXTENSIONS` constant in `helpers` module, by @HardNorth
614
### Fixed
715
- Issue [#228](https://github.com/reportportal/client-Python/issues/228): AttributeError on very large request, by @HardNorth

reportportal_client/aio/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ async def session(self) -> RetryingClientSession:
161161
ssl_config = False
162162
else:
163163
if type(self.verify_ssl) is str:
164-
ssl_config = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH, cafile=self.verify_ssl)
164+
ssl_config = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=self.verify_ssl)
165165
else:
166-
ssl_config = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH, cafile=certifi.where())
166+
ssl_config = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=certifi.where())
167167

168168
connection_params = {
169169
'ssl': ssl_config,

reportportal_client/helpers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,19 @@ def guess_content_type_from_bytes(data: Union[bytes, bytearray, List[int]]) -> s
477477
return 'application/pdf'
478478

479479
return 'application/octet-stream'
480+
481+
482+
def to_bool(value: Optional[Any]) -> Optional[bool]:
483+
"""Convert value of any type to boolean or raise ValueError.
484+
485+
:param value: value to convert
486+
:return: boolean value
487+
:raises ValueError: if value is not boolean
488+
"""
489+
if value is None:
490+
return None
491+
if value in {'TRUE', 'True', 'true', '1', 'Y', 'y', 1, True}:
492+
return True
493+
if value in {'FALSE', 'False', 'false', '0', 'N', 'n', 0, False}:
494+
return False
495+
raise ValueError(f'Invalid boolean value {value}.')

reportportal_client/logs/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ def _log(self, level, msg, args, exc_info=None, extra=None,
5858
# exception on some versions of IronPython. We trap it here so that
5959
# IronPython can use logging.
6060
try:
61+
if sys.version_info >= (3, 11):
62+
kwargs.setdefault('stacklevel', 2)
6163
if 'stacklevel' in kwargs:
6264
fn, lno, func, sinfo = \
6365
self.findCaller(stack_info, kwargs['stacklevel'])

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from setuptools import setup, find_packages
66

7-
__version__ = '5.5.6'
7+
__version__ = '5.5.7'
88

99
TYPE_STUBS = ['*.pyi']
1010

@@ -45,6 +45,7 @@ def read_file(fname):
4545
'Programming Language :: Python :: 3.9',
4646
'Programming Language :: Python :: 3.10',
4747
'Programming Language :: Python :: 3.11',
48+
'Programming Language :: Python :: 3.12',
4849
],
4950
install_requires=read_file('requirements.txt').splitlines(),
5051
)

tests/logs/test_rp_logger.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def test_record_make(logger_handler):
4040
logger.info('test_log')
4141
record = verify_record(logger_handler)
4242
assert not getattr(record, 'attachment')
43+
assert record.pathname == __file__
4344

4445

4546
@mock.patch('reportportal_client.logs.logging.Logger.handle')
@@ -86,3 +87,4 @@ def test_stacklevel_record_make(logger_handler):
8687
stack_info=inspect.stack(), stacklevel=2)
8788
record = verify_record(logger_handler)
8889
assert record.stack_info.endswith("logger.error('test_log', exc_info=RuntimeError('test'),")
90+
assert record.pathname == __file__

tests/test_helpers.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
import pytest
2020

2121
from reportportal_client.helpers import (
22-
gen_attributes,
23-
get_launch_sys_attrs,
22+
gen_attributes, get_launch_sys_attrs, to_bool,
2423
verify_value_length, ATTRIBUTE_LENGTH_LIMIT, TRUNCATE_REPLACEMENT, guess_content_type_from_bytes, is_binary
2524
)
2625

@@ -134,3 +133,36 @@ def test_binary_content_type_detection(file, expected_type):
134133
with open(file, 'rb') as f:
135134
content = f.read()
136135
assert guess_content_type_from_bytes(content) == expected_type
136+
137+
138+
@pytest.mark.parametrize(
139+
'value, expected_result',
140+
[
141+
('TRUE', True),
142+
('True', True),
143+
('true', True),
144+
('Y', True),
145+
('y', True),
146+
(True, True),
147+
(1, True),
148+
('1', True),
149+
('FALSE', False),
150+
('False', False),
151+
('false', False),
152+
('N', False),
153+
('n', False),
154+
(False, False),
155+
(0, False),
156+
('0', False),
157+
(None, None),
158+
]
159+
)
160+
def test_to_bool(value, expected_result):
161+
"""Test for validate to_bool() function."""
162+
assert to_bool(value) == expected_result
163+
164+
165+
def test_to_bool_invalid_value():
166+
"""Test for validate to_bool() function exception case."""
167+
with pytest.raises(ValueError):
168+
to_bool('invalid_value')

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ envlist =
77
py39
88
py310
99
py311
10+
py312
1011

1112
[testenv]
1213
deps =
@@ -30,3 +31,4 @@ python =
3031
3.9: py39
3132
3.10: py310
3233
3.11: py311
34+
3.12: py312

0 commit comments

Comments
 (0)