Skip to content

Commit e59e924

Browse files
committed
Add another failing test for #966
1 parent d48a3d2 commit e59e924

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

bpython/test/test_inspection.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import sys
44
import unittest
5+
from collections.abc import Sequence
56
from typing import List
67

78
from bpython import inspection
@@ -179,6 +180,44 @@ def fun_annotations(number: int, lst: List[int] = []) -> List[int]:
179180
self.assertEqual(props.argspec.args, ["number", "lst"])
180181
self.assertEqual(props.argspec.defaults[0], [])
181182

183+
@unittest.expectedFailure
184+
def test_issue_966_class_method(self):
185+
class Issue966(Sequence):
186+
@classmethod
187+
def cmethod(cls, number: int, lst: List[int] = []):
188+
"""
189+
Return a list of numbers
190+
191+
Example:
192+
========
193+
C.cmethod(1337, [1, 2]) # => [1, 2, 1337]
194+
"""
195+
return lst + [number]
196+
197+
@classmethod
198+
def bmethod(cls, number, lst):
199+
"""
200+
Return a list of numbers
201+
202+
Example:
203+
========
204+
C.cmethod(1337, [1, 2]) # => [1, 2, 1337]
205+
"""
206+
return lst + [number]
207+
208+
props = inspection.getfuncprops(
209+
"bmethod", inspection.getattr_safe(Issue966, "bmethod")
210+
)
211+
self.assertEqual(props.func, "bmethod")
212+
self.assertEqual(props.argspec.args, ["number", "lst"])
213+
214+
props = inspection.getfuncprops(
215+
"cmethod", inspection.getattr_safe(Issue966, "cmethod")
216+
)
217+
self.assertEqual(props.func, "cmethod")
218+
self.assertEqual(props.argspec.args, ["number", "lst"])
219+
self.assertEqual(props.argspec.defaults[0], [])
220+
182221

183222
class A:
184223
a = "a"

0 commit comments

Comments
 (0)