|
16 | 16 | import sys |
17 | 17 | import warnings |
18 | 18 | from collections import defaultdict |
19 | | -from random import choice as random_choice |
| 19 | +from random import shuffle |
20 | 20 | from typing import ( |
21 | 21 | Any, |
22 | 22 | Callable, |
@@ -315,25 +315,30 @@ def example(self) -> Ex: |
315 | 315 | "#drawing-interactively-in-tests for more details." |
316 | 316 | ) |
317 | 317 |
|
| 318 | + try: |
| 319 | + return self.__examples.pop() |
| 320 | + except (AttributeError, IndexError): |
| 321 | + self.__examples: List[Ex] = [] |
| 322 | + |
318 | 323 | from hypothesis.core import given |
319 | 324 |
|
320 | 325 | # Note: this function has a weird name because it might appear in |
321 | 326 | # tracebacks, and we want users to know that they can ignore it. |
322 | 327 | @given(self) |
323 | 328 | @settings( |
324 | 329 | database=None, |
325 | | - max_examples=10, |
| 330 | + max_examples=100, |
326 | 331 | deadline=None, |
327 | 332 | verbosity=Verbosity.quiet, |
328 | 333 | phases=(Phase.generate,), |
329 | 334 | suppress_health_check=HealthCheck.all(), |
330 | 335 | ) |
331 | 336 | def example_generating_inner_function(ex): |
332 | | - examples.append(ex) |
| 337 | + self.__examples.append(ex) |
333 | 338 |
|
334 | | - examples: List[Ex] = [] |
335 | 339 | example_generating_inner_function() |
336 | | - return random_choice(examples) |
| 340 | + shuffle(self.__examples) |
| 341 | + return self.__examples.pop() |
337 | 342 |
|
338 | 343 | def map(self, pack: Callable[[Ex], T]) -> "SearchStrategy[T]": |
339 | 344 | """Returns a new strategy that generates values by generating a value |
|
0 commit comments