Debian Codegraph @

hypothesis-python/tests/ghostwriter/recorded/magic_builtins.txt

raw
1 # This test code was written by the `hypothesis.extra.ghostwriter` module
2 # and is provided under the Creative Commons Zero public domain dedication.
3
4 from hypothesis import given, strategies as st
5
6 # TODO: replace st.nothing() with appropriate strategies
7
8
9 @given(x=st.nothing())
10 def test_fuzz_abs(x):
11 abs(x)
12
13
14 @given(async_iterable=st.nothing())
15 def test_fuzz_aiter(async_iterable):
16 aiter(async_iterable)
17
18
19 @given(iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())))
20 def test_fuzz_all(iterable):
21 all(iterable)
22
23
24 @given(iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())))
25 def test_fuzz_any(iterable):
26 any(iterable)
27
28
29 @given(obj=st.nothing())
30 def test_fuzz_ascii(obj):
31 ascii(obj)
32
33
34 @given(number=st.one_of(st.integers(), st.floats()))
35 def test_fuzz_bin(number):
36 bin(number)
37
38
39 @given(frm=st.nothing(), to=st.nothing())
40 def test_fuzz_bytearray_maketrans(frm, to):
41 bytearray.maketrans(frm, to)
42
43
44 @given(frm=st.nothing(), to=st.nothing())
45 def test_fuzz_bytes_maketrans(frm, to):
46 bytes.maketrans(frm, to)
47
48
49 @given(obj=st.nothing())
50 def test_fuzz_callable(obj):
51 callable(obj)
52
53
54 @given(i=st.nothing())
55 def test_fuzz_chr(i):
56 chr(i)
57
58
59 @given(
60 source=st.nothing(),
61 filename=st.nothing(),
62 mode=st.nothing(),
63 flags=st.just(0),
64 dont_inherit=st.booleans(),
65 optimize=st.just(-1),
66 _feature_version=st.just(-1),
67 )
68 def test_fuzz_compile(
69 source, filename, mode, flags, dont_inherit, optimize, _feature_version
70 ):
71 compile(
72 source=source,
73 filename=filename,
74 mode=mode,
75 flags=flags,
76 dont_inherit=dont_inherit,
77 optimize=optimize,
78 _feature_version=_feature_version,
79 )
80
81
82 @given(real=st.just(0), imag=st.just(0))
83 def test_fuzz_complex(real, imag):
84 complex(real=real, imag=imag)
85
86
87 @given(obj=st.nothing(), name=st.text())
88 def test_fuzz_delattr(obj, name):
89 delattr(obj, name)
90
91
92 @given(object=st.builds(object))
93 def test_fuzz_dir(object):
94 dir(object)
95
96
97 @given(x=st.nothing(), y=st.nothing())
98 def test_fuzz_divmod(x, y):
99 divmod(x, y)
100
101
102 @given(
103 iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
104 start=st.just(0),
105 )
106 def test_fuzz_enumerate(iterable, start):
107 enumerate(iterable=iterable, start=start)
108
109
110 @given(source=st.nothing(), globals=st.none(), locals=st.none())
111 def test_fuzz_eval(source, globals, locals):
112 eval(source, globals, locals)
113
114
115 @given(source=st.nothing(), globals=st.none(), locals=st.none())
116 def test_fuzz_exec(source, globals, locals):
117 exec(source, globals, locals)
118
119
120 @given(x=st.just(0))
121 def test_fuzz_float(x):
122 float(x)
123
124
125 @given(value=st.nothing(), format_spec=st.just(""))
126 def test_fuzz_format(value, format_spec):
127 format(value, format_spec)
128
129
130 @given(object=st.builds(object), name=st.text(), default=st.nothing())
131 def test_fuzz_getattr(object, name, default):
132 getattr(object, name, default)
133
134
135 @given(obj=st.nothing(), name=st.text())
136 def test_fuzz_hasattr(obj, name):
137 hasattr(obj, name)
138
139
140 @given(obj=st.nothing())
141 def test_fuzz_hash(obj):
142 hash(obj)
143
144
145 @given(number=st.one_of(st.integers(), st.floats()))
146 def test_fuzz_hex(number):
147 hex(number)
148
149
150 @given(obj=st.nothing())
151 def test_fuzz_id(obj):
152 id(obj)
153
154
155 @given(prompt=st.just(""))
156 def test_fuzz_input(prompt):
157 input(prompt)
158
159
160 @given(obj=st.nothing(), class_or_tuple=st.nothing())
161 def test_fuzz_isinstance(obj, class_or_tuple):
162 isinstance(obj, class_or_tuple)
163
164
165 @given(cls=st.nothing(), class_or_tuple=st.nothing())
166 def test_fuzz_issubclass(cls, class_or_tuple):
167 issubclass(cls, class_or_tuple)
168
169
170 @given(iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())))
171 def test_fuzz_iter(iterable):
172 iter(iterable)
173
174
175 @given(obj=st.nothing())
176 def test_fuzz_len(obj):
177 len(obj)
178
179
180 @given(iterable=st.just(()))
181 def test_fuzz_list(iterable):
182 list(iterable)
183
184
185 @given(
186 iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
187 default=st.nothing(),
188 key=st.nothing(),
189 )
190 def test_fuzz_max(iterable, default, key):
191 max(iterable, default=default, key=key)
192
193
194 @given(object=st.builds(object))
195 def test_fuzz_memoryview(object):
196 memoryview(object=object)
197
198
199 @given(
200 iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
201 default=st.nothing(),
202 key=st.nothing(),
203 )
204 def test_fuzz_min(iterable, default, key):
205 min(iterable, default=default, key=key)
206
207
208 @given(iterator=st.nothing(), default=st.nothing())
209 def test_fuzz_next(iterator, default):
210 next(iterator, default)
211
212
213 @given(number=st.one_of(st.integers(), st.floats()))
214 def test_fuzz_oct(number):
215 oct(number)
216
217
218 @given(
219 file=st.nothing(),
220 mode=st.just("r"),
221 buffering=st.just(-1),
222 encoding=st.none(),
223 errors=st.none(),
224 newline=st.none(),
225 closefd=st.booleans(),
226 opener=st.none(),
227 )
228 def test_fuzz_open(file, mode, buffering, encoding, errors, newline, closefd, opener):
229 open(
230 file=file,
231 mode=mode,
232 buffering=buffering,
233 encoding=encoding,
234 errors=errors,
235 newline=newline,
236 closefd=closefd,
237 opener=opener,
238 )
239
240
241 @given(c=st.nothing())
242 def test_fuzz_ord(c):
243 ord(c)
244
245
246 @given(base=st.nothing(), exp=st.nothing(), mod=st.none())
247 def test_fuzz_pow(base, exp, mod):
248 pow(base=base, exp=exp, mod=mod)
249
250
251 @given(
252 value=st.nothing(),
253 sep=st.text(),
254 end=st.nothing(),
255 file=st.nothing(),
256 flush=st.nothing(),
257 )
258 def test_fuzz_print(value, sep, end, file, flush):
259 print(value, sep=sep, end=end, file=file, flush=flush)
260
261
262 @given(fget=st.none(), fset=st.none(), fdel=st.none(), doc=st.none())
263 def test_fuzz_property(fget, fset, fdel, doc):
264 property(fget=fget, fset=fset, fdel=fdel, doc=doc)
265
266
267 @given(obj=st.nothing())
268 def test_fuzz_repr(obj):
269 repr(obj)
270
271
272 @given(sequence=st.nothing())
273 def test_fuzz_reversed(sequence):
274 reversed(sequence)
275
276
277 @given(number=st.one_of(st.integers(), st.floats()), ndigits=st.none())
278 def test_fuzz_round(number, ndigits):
279 round(number=number, ndigits=ndigits)
280
281
282 @given(obj=st.nothing(), name=st.text(), value=st.nothing())
283 def test_fuzz_setattr(obj, name, value):
284 setattr(obj, name, value)
285
286
287 @given(
288 iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
289 key=st.none(),
290 reverse=st.booleans(),
291 )
292 def test_fuzz_sorted(iterable, key, reverse):
293 sorted(iterable, key=key, reverse=reverse)
294
295
296 @given(
297 iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
298 start=st.just(0),
299 )
300 def test_fuzz_sum(iterable, start):
301 sum(iterable, start=start)
302
303
304 @given(iterable=st.just(()))
305 def test_fuzz_tuple(iterable):
306 tuple(iterable)
307
308
309 @given(object=st.builds(object))
310 def test_fuzz_vars(object):
311 vars(object)