Skip to content

Commit f010a3e

Browse files
committed
Refactoring tests for readability
1 parent 70615c2 commit f010a3e

File tree

4 files changed

+7
-137
lines changed

4 files changed

+7
-137
lines changed

tests/functional/m/method_hidden.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# pylint: disable=too-few-public-methods,missing-docstring
22
# pylint: disable=unused-private-member
3-
# pylint: disable=import-error
43
"""check method hiding ancestor attribute
54
"""
65
import functools as ft
7-
import something_else as functools
6+
import something_else as functools # pylint: disable=import-error
87

98

109
class Abcd:

tests/functional/m/method_hidden.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
method-hidden:20:4:20:12:Cdef.abcd:An attribute defined in functional.m.method_hidden line 14 hides this method:UNDEFINED
2-
method-hidden:88:4:88:11:One.one:An attribute defined in functional.m.method_hidden line 86 hides this method:UNDEFINED
3-
method-hidden:116:4:116:18:Child._protected:An attribute defined in functional.m.method_hidden line 111 hides this method:UNDEFINED
1+
method-hidden:19:4:19:12:Cdef.abcd:An attribute defined in functional.m.method_hidden line 13 hides this method:UNDEFINED
2+
method-hidden:87:4:87:11:One.one:An attribute defined in functional.m.method_hidden line 85 hides this method:UNDEFINED
3+
method-hidden:115:4:115:18:Child._protected:An attribute defined in functional.m.method_hidden line 110 hides this method:UNDEFINED
+3-129
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,16 @@
11
# pylint: disable=too-few-public-methods,missing-docstring
2-
# pylint: disable=unused-private-member
3-
# pylint: disable=import-error
42
"""check method hiding ancestor attribute
53
"""
6-
import functools as ft
7-
import something_else as functools
8-
9-
10-
class Abcd:
11-
"""dummy"""
12-
13-
def __init__(self):
14-
self.abcd = 1
15-
16-
17-
class Cdef(Abcd):
18-
"""dummy"""
19-
20-
def abcd(self): # [method-hidden]
21-
"""test"""
22-
print(self)
23-
24-
25-
class AbcdMixin:
26-
def abcd(self):
27-
pass
28-
29-
30-
class Dabc(AbcdMixin, Abcd):
31-
def abcd(self):
32-
pass
33-
34-
35-
class CustomProperty:
36-
"""dummy"""
37-
38-
def __init__(self, _):
39-
pass
40-
41-
def __get__(self, obj, __):
42-
if not obj:
43-
return self
44-
return 5
45-
46-
def __set__(self, _, __):
47-
pass
48-
49-
50-
class Ddef:
51-
"""dummy"""
52-
53-
def __init__(self):
54-
self.five = "five"
55-
56-
@CustomProperty
57-
def five(self):
58-
"""Always 5."""
59-
return self
60-
61-
62-
def my_decorator(*args, **kwargs):
63-
return CustomProperty(*args, **kwargs)
64-
65-
66-
class Foo:
67-
def __init__(self):
68-
self._bar = 42
69-
self._baz = 84
70-
71-
@my_decorator
72-
def method(self): # E0202
73-
return self._baz
74-
75-
@method.setter
76-
def method(self, value):
77-
self._baz = value
78-
79-
def do_something_with_baz(self, value):
80-
self.method = value
81-
82-
83-
class One:
84-
def __init__(self, one=None):
85-
if one is not None:
86-
self.one = one
87-
88-
def one(self): # [method-hidden]
89-
pass
90-
91-
92-
class Two(One):
93-
def one(self):
94-
pass
95-
96-
97-
try:
98-
import unknown as js
99-
except ImportError:
100-
import json as js
101-
102-
103-
class JsonEncoder(js.JSONEncoder):
104-
# pylint: disable=useless-super-delegation,super-with-arguments
105-
def default(self, o):
106-
return super(JsonEncoder, self).default(o)
4+
import something_else as functools # pylint: disable=import-error
1075

1086

1097
class Parent:
1108
def __init__(self):
1119
self._protected = None
112-
self._protected_two = None
113-
self._protected_three = None
11410

11511

11612
class Child(Parent):
117-
def _protected(self): # [method-hidden]
118-
pass
119-
120-
121-
class CachedChild(Parent):
122-
@ft.cached_property
123-
def _protected(self):
124-
pass
125-
126-
@functools.cached_property
127-
def _protected_two(self):
128-
pass
129-
13013
@functools().cached_property
131-
def _protected_three(self):
132-
pass
133-
134-
135-
class ParentTwo:
136-
def __init__(self):
137-
self.__private = None
138-
139-
140-
class ChildTwo(ParentTwo):
141-
def __private(self):
14+
def _protected(self):
15+
# This test case is only valid for python3.9 and above
14216
pass

tests/functional/m/method_hidden_py39.txt

-3
This file was deleted.

0 commit comments

Comments
 (0)