Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit529f1fa

Browse files
JohnVillalovosnejch
authored andcommitted
fix: user.warn() to show correct filename of issue
Previously would only go to the 2nd level of the stack for determiningthe offending filename and line number. When it should be showing thefirst filename outside of the python-gitlab source code. As we want itto show the warning for the user of the libraries code.Update test to show it works as expected.
1 parente11d889 commit529f1fa

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

‎gitlab/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ def warn(
191191
stacklevel=1
192192
warning_from=""
193193
forstacklevel,frameinenumerate(reversed(stack),start=1):
194-
ifstacklevel==2:
195-
warning_from=f" (python-gitlab:{frame.filename}:{frame.lineno})"
194+
warning_from=f" (python-gitlab:{frame.filename}:{frame.lineno})"
196195
frame_dir=str(pathlib.Path(frame.filename).parent.resolve())
197196
ifnotframe_dir.startswith(str(pg_dir)):
198197
break

‎tests/functional/api/test_gitlab.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ def test_list_default_warning(gl):
252252
assertlen(record)==1
253253
warning=record[0]
254254
assert__file__==warning.filename
255+
assert__file__instr(warning.message)
255256

256257

257258
deftest_list_page_nowarning(gl,recwarn):

‎tests/unit/test_gitlab_http_methods.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,7 @@ def test_list_request_pagination_warning(gl):
600600
message=str(warning.message)
601601
assert"Calling a `list()` method"inmessage
602602
assert"python-gitlab.readthedocs.io"inmessage
603+
assert__file__inmessage
603604
assert__file__==warning.filename
604605
assertisinstance(result,list)
605606
assertlen(result)==20

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp