FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pytype/pytype/compare_test.py at main · r-o-main/pytype · GitHub
r-o-main
pytype
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pytype
/
pytype
/
compare_test.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
341 lines (285 loc) · 14.5 KB
Breadcrumbs
pytype
/
pytype
/
compare_test.py
Copy path
File metadata and controls
341 lines (285 loc) · 14.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
"""Tests for compare.py."""
from
pytype
import
compare
from
pytype
import
config
from
pytype
.
abstract
import
abstract
from
pytype
.
abstract
import
abstract_utils
from
pytype
.
abstract
import
function
from
pytype
.
pytd
import
pytd
from
pytype
.
pytd
import
slots
from
pytype
.
tests
import
test_base
from
pytype
.
tests
import
test_utils
import
unittest
class
CompareTestBase
(
test_base
.
UnitTest
):
def
setUp
(
self
):
super
().
setUp
()
options
=
config
.
Options
.
create
(
python_version
=
self
.
python_version
)
self
.
_ctx
=
test_utils
.
make_context
(
options
)
self
.
_program
=
self
.
_ctx
.
program
self
.
_node
=
self
.
_ctx
.
root_node
.
ConnectNew
(
"test_node"
)
self
.
_convert
=
self
.
_ctx
.
convert
def
assertTruthy
(
self
,
value
):
self
.
assertIs
(
True
,
compare
.
compatible_with
(
value
,
True
))
self
.
assertIs
(
False
,
compare
.
compatible_with
(
value
,
False
))
def
assertFalsy
(
self
,
value
):
self
.
assertIs
(
False
,
compare
.
compatible_with
(
value
,
True
))
self
.
assertIs
(
True
,
compare
.
compatible_with
(
value
,
False
))
def
assertAmbiguous
(
self
,
value
):
self
.
assertIs
(
True
,
compare
.
compatible_with
(
value
,
True
))
self
.
assertIs
(
True
,
compare
.
compatible_with
(
value
,
False
))
class
InstanceTest
(
CompareTestBase
):
def
test_compatible_with_object
(
self
):
# object() is not compatible with False
i
=
abstract
.
Instance
(
self
.
_convert
.
object_type
,
self
.
_ctx
)
self
.
assertTruthy
(
i
)
def
test_compatible_with_numeric
(
self
):
# Numbers can evaluate to True or False
i
=
abstract
.
Instance
(
self
.
_convert
.
int_type
,
self
.
_ctx
)
self
.
assertAmbiguous
(
i
)
def
test_compatible_with_list
(
self
):
i
=
abstract
.
List
([],
self
.
_ctx
)
# Empty list is not compatible with True.
self
.
assertFalsy
(
i
)
# Once a type parameter is set, list is compatible with True and False.
i
.
merge_instance_type_parameter
(
self
.
_node
,
abstract_utils
.
T
,
self
.
_convert
.
object_type
.
to_variable
(
self
.
_ctx
.
root_node
))
self
.
assertAmbiguous
(
i
)
def
test_compatible_with_set
(
self
):
i
=
abstract
.
Instance
(
self
.
_convert
.
set_type
,
self
.
_ctx
)
# Empty set is not compatible with True.
self
.
assertFalsy
(
i
)
# Once a type parameter is set, list is compatible with True and False.
i
.
merge_instance_type_parameter
(
self
.
_node
,
abstract_utils
.
T
,
self
.
_convert
.
object_type
.
to_variable
(
self
.
_ctx
.
root_node
))
self
.
assertAmbiguous
(
i
)
def
test_compatible_with_none
(
self
):
# This test is specifically for abstract.Instance, so we don't use
# self._convert.none, which is a ConcreteValue.
i
=
abstract
.
Instance
(
self
.
_convert
.
none_type
,
self
.
_ctx
)
self
.
assertFalsy
(
i
)
def
test_compare_frozensets
(
self
):
"""Test that two frozensets can be compared for equality."""
fset
=
self
.
_convert
.
frozenset_type
i
=
abstract
.
Instance
(
fset
,
self
.
_ctx
)
j
=
abstract
.
Instance
(
fset
,
self
.
_ctx
)
self
.
assertIs
(
None
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
i
,
j
))
class
TupleTest
(
CompareTestBase
):
def
setUp
(
self
):
super
().
setUp
()
self
.
_var
=
self
.
_program
.
NewVariable
()
self
.
_var
.
AddBinding
(
abstract
.
Unknown
(
self
.
_ctx
), [],
self
.
_node
)
def
test_compatible_with__not_empty
(
self
):
t
=
self
.
_ctx
.
convert
.
tuple_to_value
((
self
.
_var
,))
self
.
assertTruthy
(
t
)
def
test_compatible_with__empty
(
self
):
t
=
self
.
_ctx
.
convert
.
tuple_to_value
(())
self
.
assertFalsy
(
t
)
def
test_getitem__concrete_index
(
self
):
t
=
self
.
_ctx
.
convert
.
tuple_to_value
((
self
.
_var
,))
index
=
self
.
_convert
.
constant_to_var
(
0
)
node
,
var
=
t
.
cls
.
getitem_slot
(
self
.
_node
,
index
)
self
.
assertIs
(
node
,
self
.
_node
)
self
.
assertIs
(
abstract_utils
.
get_atomic_value
(
var
),
abstract_utils
.
get_atomic_value
(
self
.
_var
))
def
test_getitem__abstract_index
(
self
):
t
=
self
.
_ctx
.
convert
.
tuple_to_value
((
self
.
_var
,))
index
=
self
.
_convert
.
build_int
(
self
.
_node
)
node
,
var
=
t
.
cls
.
getitem_slot
(
self
.
_node
,
index
)
self
.
assertIs
(
node
,
self
.
_node
)
self
.
assertIs
(
abstract_utils
.
get_atomic_value
(
var
),
abstract_utils
.
get_atomic_value
(
self
.
_var
))
def
test_cmp_rel__equal
(
self
):
tup
=
self
.
_convert
.
constant_to_value
((
3
,
1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LT
,
tup
,
tup
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LE
,
tup
,
tup
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
tup
,
tup
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
NE
,
tup
,
tup
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GE
,
tup
,
tup
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GT
,
tup
,
tup
))
def
test_cmp_rel__not_equal
(
self
):
tup1
=
self
.
_convert
.
constant_to_value
((
3
,
1
))
tup2
=
self
.
_convert
.
constant_to_value
((
3
,
5
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LT
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LT
,
tup2
,
tup1
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LE
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LE
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
tup2
,
tup1
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
NE
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
NE
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GE
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GE
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GT
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GT
,
tup2
,
tup1
))
def
test_cmp_rel__unknown
(
self
):
tup1
=
self
.
_convert
.
constant_to_value
((
3
,
1
))
tup2
=
abstract
.
Instance
(
self
.
_convert
.
tuple_type
,
self
.
_ctx
)
for
op
in
(
slots
.
LT
,
slots
.
LE
,
slots
.
EQ
,
slots
.
NE
,
slots
.
GE
,
slots
.
GT
):
self
.
assertIsNone
(
compare
.
cmp_rel
(
self
.
_ctx
,
op
,
tup1
,
tup2
))
self
.
assertIsNone
(
compare
.
cmp_rel
(
self
.
_ctx
,
op
,
tup2
,
tup1
))
def
test_cmp_rel__prefix_equal
(
self
):
tup1
=
self
.
_ctx
.
convert
.
tuple_to_value
(
(
self
.
_convert
.
constant_to_value
(
3
).
to_variable
(
self
.
_node
),
self
.
_convert
.
constant_to_value
(
1
).
to_variable
(
self
.
_node
),
self
.
_convert
.
primitive_class_instances
[
int
].
to_variable
(
self
.
_node
)))
tup2
=
self
.
_convert
.
constant_to_value
((
3
,
1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LT
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LT
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LE
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LE
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
tup2
,
tup1
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
NE
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
NE
,
tup2
,
tup1
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GE
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GE
,
tup2
,
tup1
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GT
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GT
,
tup2
,
tup1
))
def
test_cmp_rel__prefix_not_equal
(
self
):
tup1
=
self
.
_ctx
.
convert
.
tuple_to_value
(
(
self
.
_convert
.
constant_to_value
(
3
).
to_variable
(
self
.
_node
),
self
.
_convert
.
constant_to_value
(
1
).
to_variable
(
self
.
_node
),
self
.
_convert
.
primitive_class_instances
[
int
].
to_variable
(
self
.
_node
)))
tup2
=
self
.
_convert
.
constant_to_value
((
4
,
2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LT
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LT
,
tup2
,
tup1
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LE
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
LE
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
tup1
,
tup2
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
EQ
,
tup2
,
tup1
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
NE
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
NE
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GE
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GE
,
tup2
,
tup1
))
self
.
assertIs
(
False
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GT
,
tup1
,
tup2
))
self
.
assertIs
(
True
,
compare
.
cmp_rel
(
self
.
_ctx
,
slots
.
GT
,
tup2
,
tup1
))
def
test_cmp_rel__prefix_unknown
(
self
):
tup1
=
self
.
_ctx
.
convert
.
tuple_to_value
(
(
self
.
_convert
.
constant_to_value
(
3
).
to_variable
(
self
.
_node
),
self
.
_convert
.
primitive_class_instances
[
int
].
to_variable
(
self
.
_node
)))
tup2
=
self
.
_convert
.
constant_to_value
((
3
,
1
))
for
op
in
(
slots
.
LT
,
slots
.
LE
,
slots
.
EQ
,
slots
.
NE
,
slots
.
GE
,
slots
.
GT
):
self
.
assertIsNone
(
compare
.
cmp_rel
(
self
.
_ctx
,
op
,
tup1
,
tup2
))
self
.
assertIsNone
(
compare
.
cmp_rel
(
self
.
_ctx
,
op
,
tup2
,
tup1
))
class
DictTest
(
CompareTestBase
):
def
setUp
(
self
):
super
().
setUp
()
self
.
_d
=
abstract
.
Dict
(
self
.
_ctx
)
self
.
_var
=
self
.
_program
.
NewVariable
()
self
.
_var
.
AddBinding
(
abstract
.
Unknown
(
self
.
_ctx
), [],
self
.
_node
)
def
test_compatible_with__when_empty
(
self
):
self
.
assertFalsy
(
self
.
_d
)
def
test_compatible_with__after_setitem
(
self
):
# Once a slot is added, dict is ambiguous.
self
.
_d
.
setitem_slot
(
self
.
_node
,
self
.
_var
,
self
.
_var
)
self
.
assertAmbiguous
(
self
.
_d
)
def
test_compatible_with__after_set_str_item
(
self
):
self
.
_d
.
set_str_item
(
self
.
_node
,
"key"
,
self
.
_var
)
self
.
assertTruthy
(
self
.
_d
)
def
test_compatible_with__after_unknown_update
(
self
):
# Updating an empty dict with an unknown value makes the former ambiguous.
self
.
_d
.
update
(
self
.
_node
,
abstract
.
Unknown
(
self
.
_ctx
))
self
.
assertAmbiguous
(
self
.
_d
)
def
test_compatible_with__after_empty_update
(
self
):
empty_dict
=
abstract
.
Dict
(
self
.
_ctx
)
self
.
_d
.
update
(
self
.
_node
,
empty_dict
)
self
.
assertFalsy
(
self
.
_d
)
def
test_compatible_with__after_unambiguous_update
(
self
):
unambiguous_dict
=
abstract
.
Dict
(
self
.
_ctx
)
unambiguous_dict
.
set_str_item
(
self
.
_node
,
"a"
,
self
.
_ctx
.
new_unsolvable
(
self
.
_node
))
self
.
_d
.
update
(
self
.
_node
,
unambiguous_dict
)
self
.
assertTruthy
(
self
.
_d
)
def
test_compatible_with__after_ambiguous_update
(
self
):
ambiguous_dict
=
abstract
.
Dict
(
self
.
_ctx
)
ambiguous_dict
.
merge_instance_type_parameter
(
self
.
_node
,
abstract_utils
.
K
,
self
.
_ctx
.
new_unsolvable
(
self
.
_node
))
ambiguous_dict
.
could_contain_anything
=
True
self
.
_d
.
update
(
self
.
_node
,
ambiguous_dict
)
self
.
assertAmbiguous
(
self
.
_d
)
def
test_compatible_with__after_concrete_update
(
self
):
self
.
_d
.
update
(
self
.
_node
, {})
self
.
assertFalsy
(
self
.
_d
)
self
.
_d
.
update
(
self
.
_node
, {
"a"
:
self
.
_ctx
.
new_unsolvable
(
self
.
_node
)})
self
.
assertTruthy
(
self
.
_d
)
def
test_pop
(
self
):
self
.
_d
.
set_str_item
(
self
.
_node
,
"a"
,
self
.
_var
)
node
,
ret
=
self
.
_d
.
pop_slot
(
self
.
_node
,
self
.
_convert
.
build_string
(
self
.
_node
,
"a"
))
self
.
assertFalsy
(
self
.
_d
)
self
.
assertIs
(
node
,
self
.
_node
)
self
.
assertIs
(
ret
,
self
.
_var
)
def
test_pop_with_default
(
self
):
self
.
_d
.
set_str_item
(
self
.
_node
,
"a"
,
self
.
_var
)
node
,
ret
=
self
.
_d
.
pop_slot
(
self
.
_node
,
self
.
_convert
.
build_string
(
self
.
_node
,
"a"
),
self
.
_convert
.
none
.
to_variable
(
self
.
_node
))
# default is ignored
self
.
assertFalsy
(
self
.
_d
)
self
.
assertIs
(
node
,
self
.
_node
)
self
.
assertIs
(
ret
,
self
.
_var
)
def
test_bad_pop
(
self
):
self
.
_d
.
set_str_item
(
self
.
_node
,
"a"
,
self
.
_var
)
self
.
assertRaises
(
function
.
DictKeyMissing
,
self
.
_d
.
pop_slot
,
self
.
_node
,
self
.
_convert
.
build_string
(
self
.
_node
,
"b"
))
self
.
assertTruthy
(
self
.
_d
)
def
test_bad_pop_with_default
(
self
):
val
=
self
.
_convert
.
primitive_class_instances
[
int
]
self
.
_d
.
set_str_item
(
self
.
_node
,
"a"
,
val
.
to_variable
(
self
.
_node
))
node
,
ret
=
self
.
_d
.
pop_slot
(
self
.
_node
,
self
.
_convert
.
build_string
(
self
.
_node
,
"b"
),
self
.
_convert
.
none
.
to_variable
(
self
.
_node
))
self
.
assertTruthy
(
self
.
_d
)
self
.
assertIs
(
node
,
self
.
_node
)
self
.
assertListEqual
(
ret
.
data
, [
self
.
_convert
.
none
])
def
test_ambiguous_pop
(
self
):
val
=
self
.
_convert
.
primitive_class_instances
[
int
]
self
.
_d
.
set_str_item
(
self
.
_node
,
"a"
,
val
.
to_variable
(
self
.
_node
))
ambiguous_key
=
self
.
_convert
.
primitive_class_instances
[
str
]
node
,
ret
=
self
.
_d
.
pop_slot
(
self
.
_node
,
ambiguous_key
.
to_variable
(
self
.
_node
))
self
.
assertAmbiguous
(
self
.
_d
)
self
.
assertIs
(
node
,
self
.
_node
)
self
.
assertListEqual
(
ret
.
data
, [
val
])
def
test_ambiguous_pop_with_default
(
self
):
val
=
self
.
_convert
.
primitive_class_instances
[
int
]
self
.
_d
.
set_str_item
(
self
.
_node
,
"a"
,
val
.
to_variable
(
self
.
_node
))
ambiguous_key
=
self
.
_convert
.
primitive_class_instances
[
str
]
default_var
=
self
.
_convert
.
none
.
to_variable
(
self
.
_node
)
node
,
ret
=
self
.
_d
.
pop_slot
(
self
.
_node
,
ambiguous_key
.
to_variable
(
self
.
_node
),
default_var
)
self
.
assertAmbiguous
(
self
.
_d
)
self
.
assertIs
(
node
,
self
.
_node
)
self
.
assertSetEqual
(
set
(
ret
.
data
), {
val
,
self
.
_convert
.
none
})
def
test_ambiguous_dict_after_pop
(
self
):
ambiguous_key
=
self
.
_convert
.
primitive_class_instances
[
str
]
val
=
self
.
_convert
.
primitive_class_instances
[
int
]
node
,
_
=
self
.
_d
.
setitem_slot
(
self
.
_node
,
ambiguous_key
.
to_variable
(
self
.
_node
),
val
.
to_variable
(
self
.
_node
))
_
,
ret
=
self
.
_d
.
pop_slot
(
node
,
self
.
_convert
.
build_string
(
node
,
"a"
))
self
.
assertAmbiguous
(
self
.
_d
)
self
.
assertListEqual
(
ret
.
data
, [
val
])
def
test_ambiguous_dict_after_pop_with_default
(
self
):
ambiguous_key
=
self
.
_convert
.
primitive_class_instances
[
str
]
val
=
self
.
_convert
.
primitive_class_instances
[
int
]
node
,
_
=
self
.
_d
.
setitem_slot
(
self
.
_node
,
ambiguous_key
.
to_variable
(
self
.
_node
),
val
.
to_variable
(
self
.
_node
))
_
,
ret
=
self
.
_d
.
pop_slot
(
node
,
self
.
_convert
.
build_string
(
node
,
"a"
),
self
.
_convert
.
none
.
to_variable
(
node
))
self
.
assertAmbiguous
(
self
.
_d
)
self
.
assertSetEqual
(
set
(
ret
.
data
), {
val
,
self
.
_convert
.
none
})
class
FunctionTest
(
CompareTestBase
):
def
test_compatible_with
(
self
):
pytd_sig
=
pytd
.
Signature
((),
None
,
None
,
pytd
.
AnythingType
(), (), ())
sig
=
abstract
.
PyTDSignature
(
"f"
,
pytd_sig
,
self
.
_ctx
)
f
=
abstract
.
PyTDFunction
(
"f"
, (
sig
,),
pytd
.
MethodKind
.
METHOD
,
self
.
_ctx
)
self
.
assertTruthy
(
f
)
class
ClassTest
(
CompareTestBase
):
def
test_compatible_with
(
self
):
cls
=
abstract
.
InterpreterClass
(
"X"
, [], {},
None
,
self
.
_ctx
)
self
.
assertTruthy
(
cls
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Back
|
FazBrowse Home
|
New Git URL