diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unittest_inference.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py index 7fc5990a..b2210a8d 100644 --- a/tests/unittest_inference.py +++ b/tests/unittest_inference.py @@ -5775,5 +5775,21 @@ def test_recursion_error_self_reference_type_call(): assert [cls.name for cls in inferred.mro()] == ["B", "A", "object"] +def test_allow_retrieving_instance_attrs_and_special_attrs_for_functions(): + code = """ + class A: + def test(self): + "a" + # Add `__doc__` to `FunctionDef.instance_attrs` via an `AugAssign` + test.__doc__ += 'b' + test #@ + """ + node = extract_node(code) + inferred = next(node.infer()) + attrs = inferred.getattr("__doc__") + # One from the `AugAssign`, one from the special attributes + assert len(attrs) == 2 + + if __name__ == "__main__": unittest.main() |
