Skip to content

Commit 1332d18

Browse files
committed
Test inspection with static methods
This is another variant of the class from #966.
1 parent 3ad203d commit 1332d18

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

bpython/test/test_inspection.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,43 @@ def bmethod(cls, number, lst):
218218
self.assertEqual(props.argspec.args, ["number", "lst"])
219219
self.assertEqual(props.argspec.defaults[0], [])
220220

221+
def test_issue_966_static_method(self):
222+
class Issue966(Sequence):
223+
@staticmethod
224+
def cmethod(number: int, lst: List[int] = []):
225+
"""
226+
Return a list of numbers
227+
228+
Example:
229+
========
230+
C.cmethod(1337, [1, 2]) # => [1, 2, 1337]
231+
"""
232+
return lst + [number]
233+
234+
@staticmethod
235+
def bmethod(number, lst):
236+
"""
237+
Return a list of numbers
238+
239+
Example:
240+
========
241+
C.cmethod(1337, [1, 2]) # => [1, 2, 1337]
242+
"""
243+
return lst + [number]
244+
245+
props = inspection.getfuncprops(
246+
"bmethod", inspection.getattr_safe(Issue966, "bmethod")
247+
)
248+
self.assertEqual(props.func, "bmethod")
249+
self.assertEqual(props.argspec.args, ["number", "lst"])
250+
251+
props = inspection.getfuncprops(
252+
"cmethod", inspection.getattr_safe(Issue966, "cmethod")
253+
)
254+
self.assertEqual(props.func, "cmethod")
255+
self.assertEqual(props.argspec.args, ["number", "lst"])
256+
self.assertEqual(props.argspec.defaults[0], [])
257+
221258

222259
class A:
223260
a = "a"

0 commit comments

Comments
 (0)