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

Commitf6028e6

Browse files
chore: add the version of python-gitlab to Exception
People will post tracebacks of AttributeError exceptions but not postinformation on the version of python-gitlab used.Add the version of python-gitlab to the AttributeError exceptionmessage.
1 parenta825844 commitf6028e6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

‎gitlab/base.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def __getattr__(self, name: str) -> Any:
129129
exceptKeyErrorasexc:
130130
message= (
131131
f"{type(self).__name__!r} object has no attribute{name!r}"
132+
f" (python-gitlab version:{gitlab.__version__})"
132133
)
133134
ifself._created_from_list:
134135
message= (

‎tests/unit/test_base.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ def test_missing_attribute_does_not_raise_custom(self, fake_gitlab, fake_manager
103103
assert"was created via a list()"notinexc_str
104104
assertbase._URL_ATTRIBUTE_ERRORnotinexc_str
105105

106+
deftest_missing_attribute_has_pg_version(self,fake_gitlab,fake_manager):
107+
"""Ensure a missing attribute raise our custom error message with the
108+
version of python-gitlab"""
109+
obj=FakeObject(manager=fake_manager,attrs={"foo":"bar"})
110+
withpytest.raises(AttributeError)asexcinfo:
111+
obj.missing_attribute
112+
exc_str=str(excinfo.value)
113+
pg_version_str=f"(python-gitlab version:{gitlab.__version__})"
114+
assertpg_version_strinexc_str
115+
106116
deftest_missing_attribute_from_list_raises_custom(self,fake_gitlab,fake_manager):
107117
"""Ensure a missing attribute raises our custom error message if the
108118
RESTObject was created from a list"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp