Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc7f5bb

Browse files
committed
add async def cases
1 parent 3cbde0d commit fc7f5bb

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

Lib/test/test_symtable.py

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,30 @@ def generic_spam[T](a):
5252
class GenericMine[T: int]:
5353
pass
5454
55-
# test case: ComplexClass
55+
# The following symbols are defined in ComplexClass
56+
# without being introduced by a 'global' statement.
5657
glob_unassigned_meth: int
5758
glob_unassigned_meth_pep_695: int
59+
glob_unassigned_async_meth: int
60+
glob_unassigned_async_meth_pep_695: int
61+
5862
glob_assigned_meth = 1234
5963
glob_assigned_meth_pep_695 = 1234
64+
glob_assigned_async_meth = 1234
65+
glob_assigned_async_meth_pep_695 = 1234
6066
67+
# The following symbols are defined in ComplexClass after
68+
# being introduced by a 'global' statement (and therefore
69+
# are not considered as methods of ComplexClass).
6170
glob_unassigned_meth_ignore: int
6271
glob_unassigned_meth_pep_695_ignore: int
72+
glob_unassigned_async_meth_ignore: int
73+
glob_unassigned_async_meth_pep_695_ignore: int
74+
6375
glob_assigned_meth_ignore = 1234
6476
glob_assigned_meth_pep_695_ignore = 1234
77+
glob_assigned_async_meth_ignore = 1234
78+
glob_assigned_async_meth_pep_695_ignore = 1234
6579
6680
class ComplexClass:
6781
some_non_method_const = 1234
@@ -78,40 +92,74 @@ class some_non_method_nested_pep_695[T]: pass
7892
def a_method(self): pass
7993
def a_method_pep_695[T](self): pass
8094
95+
async def an_async_method(self): pass
96+
async def an_async_method_pep_695[T](self): pass
97+
8198
@classmethod
8299
def a_classmethod(cls): pass
83100
@classmethod
84101
def a_classmethod_pep_695[T](self): pass
85102
103+
@classmethod
104+
async def an_async_classmethod(cls): pass
105+
@classmethod
106+
async def an_async_classmethod_pep_695[T](self): pass
107+
86108
@staticmethod
87109
def a_staticmethod(): pass
88110
@staticmethod
89111
def a_staticmethod_pep_695[T](self): pass
90112
113+
@staticmethod
114+
def an_async_staticmethod(): pass
115+
@staticmethod
116+
def an_async_staticmethod_pep_695[T](self): pass
117+
91118
# These ones will be considered as methods because of the 'def' although
92119
# they are *not* valid methods at runtime since they are not decorated
93120
# with @staticmethod.
94121
def a_fakemethod(): pass
95122
def a_fakemethod_pep_695[T](): pass
96123
124+
async def an_async_fakemethod(): pass
125+
async def an_async_fakemethod_pep_695[T](): pass
126+
97127
# Check that those are still considered as methods
98128
# since they are not using the 'global' keyword.
99129
def glob_unassigned_meth(): pass
100130
def glob_unassigned_meth_pep_695[T](): pass
131+
132+
async def glob_unassigned_async_meth(): pass
133+
async def glob_unassigned_async_meth_pep_695[T](): pass
134+
101135
def glob_assigned_meth(): pass
102136
def glob_assigned_meth_pep_695[T](): pass
103137
138+
async def glob_assigned_async_meth(): pass
139+
async def glob_assigned_async_meth_pep_695[T](): pass
140+
104141
# The following are not picked as a method because thy are not
105142
# visible by the class at runtime (this is equivalent to having
106143
# the definitions outside of the class).
107144
global glob_unassigned_meth_ignore
108145
def glob_unassigned_meth_ignore(): pass
109146
global glob_unassigned_meth_pep_695_ignore
110147
def glob_unassigned_meth_pep_695_ignore[T](): pass
148+
149+
global glob_unassigned_async_meth_ignore
150+
async def glob_unassigned_async_meth_ignore(): pass
151+
global glob_unassigned_async_meth_pep_695_ignore
152+
async def glob_unassigned_async_meth_pep_695_ignore[T](): pass
153+
111154
global glob_assigned_meth_ignore
112155
def glob_assigned_meth_ignore(): pass
113156
global glob_assigned_meth_pep_695_ignore
114157
def glob_assigned_meth_pep_695_ignore[T](): pass
158+
159+
global glob_assigned_async_meth_ignore
160+
async def glob_assigned_async_meth_ignore(): pass
161+
global glob_assigned_async_meth_pep_695_ignore
162+
async def glob_assigned_async_meth_pep_695_ignore[T](): pass
115163
"""
116164

117165

@@ -305,11 +353,17 @@ def test_class_info(self):
305353

306354
self.assertEqual(self.ComplexClass.get_methods(), (
307355
'a_method', 'a_method_pep_695',
356+
'an_async_method', 'an_async_method_pep_695',
308357
'a_classmethod', 'a_classmethod_pep_695',
358+
'an_async_classmethod', 'an_async_classmethod_pep_695',
309359
'a_staticmethod', 'a_staticmethod_pep_695',
360+
'an_async_staticmethod', 'an_async_staticmethod_pep_695',
310361
'a_fakemethod', 'a_fakemethod_pep_695',
362+
'an_async_fakemethod', 'an_async_fakemethod_pep_695',
311363
'glob_unassigned_meth', 'glob_unassigned_meth_pep_695',
364+
'glob_unassigned_async_meth', 'glob_unassigned_async_meth_pep_695',
312365
'glob_assigned_meth', 'glob_assigned_meth_pep_695',
366+
'glob_assigned_async_meth', 'glob_assigned_async_meth_pep_695',
313367
))
314368

315369
def test_filename_correct(self):

0 commit comments

Comments
 (0)