Skip to content

Commit 1593bc1

Browse files
authored
Merge pull request #183 from reportportal/develop
Release
2 parents 6fc043d + 91d115d commit 1593bc1

File tree

10 files changed

+71
-27
lines changed

10 files changed

+71
-27
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ jobs:
6262
python setup.py sdist bdist_wheel
6363
twine upload dist/*
6464
65+
- name: Checkout develop branch
66+
uses: actions/checkout@v2
67+
with:
68+
ref: 'develop'
69+
fetch-depth: 0
70+
6571
- name: Update CHANGELOG.md
6672
id: changelogUpdate
6773
run: |
@@ -74,7 +80,6 @@ jobs:
7480
mv ${{ env.CHANGE_LOG_FILE }}${{ env.TMP_SUFFIX }} ${{ env.CHANGE_LOG_FILE }}
7581
git add ${{ env.CHANGE_LOG_FILE }}
7682
git commit -m "Changelog update"
77-
git push
7883
7984
- name: Read changelog Entry
8085
id: readChangelogEntry
@@ -95,12 +100,6 @@ jobs:
95100
draft: false
96101
prerelease: false
97102

98-
- name: Checkout develop branch
99-
uses: actions/checkout@v2
100-
with:
101-
ref: 'develop'
102-
fetch-depth: 0
103-
104103
- name: Merge release branch into develop
105104
id: mergeIntoDevelop
106105
run: |
@@ -111,11 +110,11 @@ jobs:
111110
- name: Update version file
112111
id: versionFileUpdate
113112
run: |
114-
export CURRENT_VERSION_VALUE=`echo '${{ env.CURRENT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
115-
export NEXT_VERSION_VALUE=`echo '${{ env.NEXT_VERSION }}' | sed -E 's/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/'`
113+
export CURRENT_VERSION_VALUE=`echo '${{ env.CURRENT_VERSION }}' | sed -E "s/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/"`
114+
export NEXT_VERSION_VALUE=`echo '${{ env.NEXT_VERSION }}' | sed -E "s/(.*)/${{ env.VERSION_REPLACE_PATTERN }}/"`
116115
sed "s/${CURRENT_VERSION_VALUE}/${NEXT_VERSION_VALUE}/g" ${{ env.VERSION_FILE }} > ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }}
117116
rm ${{ env.VERSION_FILE }}
118117
mv ${{ env.VERSION_FILE }}${{ env.TMP_SUFFIX }} ${{ env.VERSION_FILE }}
119118
git add ${{ env.VERSION_FILE }}
120119
git commit -m "Version update"
121-
git push origin develop
120+
git push

CHANGELOG.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22

33
## [Unreleased]
44
### Fixed
5-
- Issue [#180](https://github.com/reportportal/client-Python/issues/180):
6-
logger crash on attachments, by @HardNorth
5+
- Issue [#182](https://github.com/reportportal/client-Python/issues/182): logger crash on attachments, by @HardNorth
6+
7+
## [5.2.1]
8+
### Fixed
9+
- Issue [#180](https://github.com/reportportal/client-Python/issues/180): logger crash on attachments, by @HardNorth
710
### Changed
8-
- Log processing does not stop on the first error now.
11+
- Log processing does not stop on the first error now, by @HardNorth
912

1013
## [5.2.0]
1114
### Changed

reportportal_client/_local/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"""Report Portal client context storing and retrieving module."""
1414
from threading import local
1515

16-
1716
__INSTANCES = local()
1817

1918

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2022 https://reportportal.io .
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# https://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License
13+
14+
from typing import Optional
15+
16+
from reportportal_client.client import RPClient
17+
18+
19+
def current() -> Optional[RPClient]: ...
20+
21+
22+
def set_current(client: Optional[RPClient]) -> None: ...

reportportal_client/logs/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ def emit(self, record):
138138
Emit function.
139139
140140
:param record: a log Record of requests
141-
:return: log ID
142141
"""
143142
msg = ''
144143

@@ -152,10 +151,12 @@ def emit(self, record):
152151
for level in self._sorted_levelnos:
153152
if level <= record.levelno:
154153
rp_client = current()
155-
return rp_client.log(
156-
timestamp(),
157-
msg,
158-
level=self._loglevel_map[level],
159-
attachment=getattr(record, 'attachment'),
160-
item_id=rp_client.current_item()
161-
)
154+
if rp_client:
155+
rp_client.log(
156+
timestamp(),
157+
msg,
158+
level=self._loglevel_map[level],
159+
attachment=getattr(record, 'attachment'),
160+
item_id=rp_client.current_item()
161+
)
162+
return

reportportal_client/service.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ def log(self, time, message, level=None, attachment=None, item_id=None):
497497
:param level:
498498
:param attachment: files
499499
:param item_id: id of item
500-
:return: id of item from response
501500
"""
502501
data = {
503502
"launchUuid": self.launch_id,
@@ -509,7 +508,7 @@ def log(self, time, message, level=None, attachment=None, item_id=None):
509508
data["itemUuid"] = item_id
510509
if attachment:
511510
data["attachment"] = attachment
512-
return self._log_batch(data)
511+
self._log_batch(data)
513512

514513
def _log_batch(self, log_data, force=False):
515514
"""

reportportal_client/steps/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __enter__(self):
120120
"""Enter the runtime context related to this object."""
121121
# Cannot call _local.current() early since it will be initialized
122122
# before client put something in there
123-
rp_client = self.client if self.client else current()
123+
rp_client = self.client or current()
124124
if not rp_client:
125125
return
126126
self.__item_id = rp_client.step_reporter \
@@ -138,7 +138,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
138138
"""Exit the runtime context related to this object."""
139139
# Cannot call _local.current() early since it will be initialized
140140
# before client put something in there
141-
rp_client = self.client if self.client else current()
141+
rp_client = self.client or current()
142142
if not rp_client:
143143
return
144144
# Avoid failure in case if 'rp_client' was 'None' on function start

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup, find_packages
44

5-
__version__ = '5.2.1'
5+
__version__ = '5.2.2'
66

77
with open('requirements.txt') as f:
88
requirements = f.read().splitlines()

tests/logs/test_rp_log_handler.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,15 @@ def test_emit_custom_level(mocked_handle):
9595
assert mock_client.log.call_count == 1
9696
call_kwargs = mock_client.log.call_args[1]
9797
assert call_kwargs['level'] == 'WARN'
98+
99+
100+
@mock.patch('reportportal_client.logs.logging.Logger.handle')
101+
def test_emit_null_client_no_error(mocked_handle):
102+
test_message = 'test message'
103+
RPLogger('test_logger').log(30, test_message)
104+
record = mocked_handle.call_args[0][0]
105+
106+
set_current(None)
107+
108+
log_handler = RPLogHandler()
109+
log_handler.emit(record)

tests/steps/test_steps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,12 @@ def test_two_level_nested_step_decorator(rp_client):
194194
assert first_id.startswith('post-')
195195
assert second_id.startswith('post-')
196196
assert first_id != second_id
197+
198+
199+
def test_verify_manual_client_bypass_step(rp_client):
200+
set_current(None)
201+
rp_client._item_stack.append(PARENT_STEP_ID)
202+
with step(NESTED_STEP_NAME, rp_client=rp_client):
203+
pass
204+
assert rp_client.session.post.call_count == 1
205+
assert rp_client.session.put.call_count == 1

0 commit comments

Comments
 (0)