forked from HypothesisWorks/hypothesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magic_builtins.txt
285 lines (193 loc) · 6.11 KB
/
magic_builtins.txt
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
# This test code was written by the `hypothesis.extra.ghostwriter` module
# and is provided under the Creative Commons Zero public domain dedication.
from hypothesis import given, strategies as st
# TODO: replace st.nothing() with appropriate strategies
@given(x=st.nothing())
def test_fuzz_abs(x):
abs(x)
@given(iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())))
def test_fuzz_all(iterable):
all(iterable)
@given(iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())))
def test_fuzz_any(iterable):
any(iterable)
@given(obj=st.nothing())
def test_fuzz_ascii(obj):
ascii(obj)
@given(number=st.one_of(st.integers(), st.floats(), st.fractions()))
def test_fuzz_bin(number):
bin(number)
@given(obj=st.nothing())
def test_fuzz_callable(obj):
callable(obj)
@given(i=st.nothing())
def test_fuzz_chr(i):
chr(i)
@given(
source=st.nothing(),
filename=st.text(),
mode=st.nothing(),
flags=st.just(0),
dont_inherit=st.booleans(),
optimize=st.just(-1),
_feature_version=st.just(-1),
)
def test_fuzz_compile(
source, filename, mode, flags, dont_inherit, optimize, _feature_version
):
compile(
source=source,
filename=filename,
mode=mode,
flags=flags,
dont_inherit=dont_inherit,
optimize=optimize,
_feature_version=_feature_version,
)
@given(real=st.just(0), imag=st.just(0))
def test_fuzz_complex(real, imag):
complex(real=real, imag=imag)
@given(obj=st.nothing(), name=st.text())
def test_fuzz_delattr(obj, name):
delattr(obj, name)
@given(object=st.builds(object))
def test_fuzz_dir(object):
dir(object)
@given(x=st.nothing(), y=st.nothing())
def test_fuzz_divmod(x, y):
divmod(x, y)
@given(
iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
start=st.just(0),
)
def test_fuzz_enumerate(iterable, start):
enumerate(iterable=iterable, start=start)
@given(source=st.nothing(), globals=st.none(), locals=st.none())
def test_fuzz_eval(source, globals, locals):
eval(source, globals, locals)
@given(source=st.nothing(), globals=st.none(), locals=st.none())
def test_fuzz_exec(source, globals, locals):
exec(source, globals, locals)
@given(x=st.just(0))
def test_fuzz_float(x):
float(x)
@given(value=st.nothing(), format_spec=st.just(""))
def test_fuzz_format(value, format_spec):
format(value, format_spec)
@given(object=st.builds(object), name=st.text(), default=st.nothing())
def test_fuzz_getattr(object, name, default):
getattr(object, name, default)
@given(obj=st.nothing(), name=st.text())
def test_fuzz_hasattr(obj, name):
hasattr(obj, name)
@given(obj=st.nothing())
def test_fuzz_hash(obj):
hash(obj)
@given(number=st.one_of(st.integers(), st.floats(), st.fractions()))
def test_fuzz_hex(number):
hex(number)
@given(obj=st.nothing())
def test_fuzz_id(obj):
id(obj)
@given(prompt=st.none())
def test_fuzz_input(prompt):
input(prompt)
@given(obj=st.nothing(), class_or_tuple=st.nothing())
def test_fuzz_isinstance(obj, class_or_tuple):
isinstance(obj, class_or_tuple)
@given(cls=st.nothing(), class_or_tuple=st.nothing())
def test_fuzz_issubclass(cls, class_or_tuple):
issubclass(cls, class_or_tuple)
@given(iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())))
def test_fuzz_iter(iterable):
iter(iterable)
@given(obj=st.nothing())
def test_fuzz_len(obj):
len(obj)
@given(iterable=st.just(()))
def test_fuzz_list(iterable):
list(iterable)
@given(
iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
default=st.nothing(),
key=st.nothing(),
)
def test_fuzz_max(iterable, default, key):
max(iterable, default=default, key=key)
@given(object=st.builds(object))
def test_fuzz_memoryview(object):
memoryview(object=object)
@given(
iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
default=st.nothing(),
key=st.nothing(),
)
def test_fuzz_min(iterable, default, key):
min(iterable, default=default, key=key)
@given(iterator=st.nothing(), default=st.nothing())
def test_fuzz_next(iterator, default):
next(iterator, default)
@given(number=st.one_of(st.integers(), st.floats(), st.fractions()))
def test_fuzz_oct(number):
oct(number)
@given(
file=st.nothing(),
mode=st.just("r"),
buffering=st.just(-1),
encoding=st.none(),
errors=st.none(),
newline=st.none(),
closefd=st.booleans(),
opener=st.none(),
)
def test_fuzz_open(file, mode, buffering, encoding, errors, newline, closefd, opener):
open(
file=file,
mode=mode,
buffering=buffering,
encoding=encoding,
errors=errors,
newline=newline,
closefd=closefd,
opener=opener,
)
@given(c=st.nothing())
def test_fuzz_ord(c):
ord(c)
@given(base=st.nothing(), exp=st.nothing(), mod=st.none())
def test_fuzz_pow(base, exp, mod):
pow(base=base, exp=exp, mod=mod)
@given(fget=st.none(), fset=st.none(), fdel=st.none(), doc=st.none())
def test_fuzz_property(fget, fset, fdel, doc):
property(fget=fget, fset=fset, fdel=fdel, doc=doc)
@given(obj=st.nothing())
def test_fuzz_repr(obj):
repr(obj)
@given(sequence=st.nothing())
def test_fuzz_reversed(sequence):
reversed(sequence)
@given(number=st.one_of(st.integers(), st.floats(), st.fractions()), ndigits=st.none())
def test_fuzz_round(number, ndigits):
round(number=number, ndigits=ndigits)
@given(obj=st.nothing(), name=st.text(), value=st.nothing())
def test_fuzz_setattr(obj, name, value):
setattr(obj, name, value)
@given(
iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
key=st.none(),
reverse=st.booleans(),
)
def test_fuzz_sorted(iterable, key, reverse):
sorted(iterable, key=key, reverse=reverse)
@given(
iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
start=st.just(0),
)
def test_fuzz_sum(iterable, start):
sum(iterable, start=start)
@given(iterable=st.just(()))
def test_fuzz_tuple(iterable):
tuple(iterable)
@given(object=st.builds(object))
def test_fuzz_vars(object):
vars(object)