Skip to content

Commit

Permalink
adding file location assertion to test_rp_logger, and fixing for 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
dagansandler committed Aug 4, 2024
1 parent bd50b91 commit 9a02f94
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions reportportal_client/logs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
2 changes: 2 additions & 0 deletions tests/logs/test_rp_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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__

0 comments on commit 9a02f94

Please sign in to comment.