forked from pylint-dev/pylint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests of properties on derived classes
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
tests/functional/r/regression/regression_properties_in_class_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# pylint: disable=missing-docstring,too-few-public-methods | ||
|
||
class Meta(type): | ||
@property | ||
def values(cls): | ||
return ['foo', 'bar'] | ||
|
||
|
||
class Parent(metaclass=Meta): | ||
pass | ||
|
||
|
||
assert 'foo' in Parent.values # no warning | ||
for value in Parent.values: # no warning | ||
print(value) | ||
|
||
|
||
class Child(Parent): | ||
pass | ||
|
||
|
||
assert 'foo' in Child.values # false-positive: unsupported-membership-test | ||
for value in Child.values: # false-positive: not-an-iterable | ||
print(value) | ||
|
||
|
||
class Meta2(type): | ||
def a_method(cls): # pylint: disable=no-self-use | ||
return [123] | ||
|
||
|
||
class Parent2(metaclass=Meta2): | ||
@property | ||
def a_method(self): | ||
return "actually a property" | ||
|
||
|
||
class Child2(Parent2): | ||
pass | ||
|
||
|
||
assert 123 in Child2.a_method # [unsupported-membership-test] | ||
for value in Child2.a_method: # [not-an-iterable] | ||
print(value) |
2 changes: 2 additions & 0 deletions
2
tests/functional/r/regression/regression_properties_in_class_context.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
unsupported-membership-test:42:14::Value 'Child2.a_method' doesn't support membership test | ||
not-an-iterable:43:13::Non-iterable value Child2.a_method is used in an iterating context |