Skip to content

Commit bfc994e

Browse files
committed
deflake last tests
1 parent f0385f8 commit bfc994e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

hypothesis-python/src/hypothesis/strategies/_internal/strategies.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
)
3030

3131
from hypothesis._settings import HealthCheck, Phase, Verbosity, settings
32-
from hypothesis.control import _current_build_context
32+
from hypothesis.control import _current_build_context, current_build_context
3333
from hypothesis.errors import (
3434
HypothesisException,
3535
HypothesisWarning,
@@ -843,7 +843,7 @@ def do_draw(self, data: ConjectureData) -> Any:
843843
x = data.draw(self.mapped_strategy)
844844
result = self.pack(x) # type: ignore
845845
data.stop_example()
846-
_current_build_context.value.record_call(result, self.pack, [x], {})
846+
current_build_context().record_call(result, self.pack, [x], {})
847847
return result
848848
except UnsatisfiedAssumption:
849849
data.stop_example(discard=True)

hypothesis-python/tests/conjecture/test_alt_backend.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,10 @@ def draw_bytes(
155155
return forced
156156
max_size = 100 if max_size is None else max_size
157157
size = self.prng.randint(min_size, max_size)
158-
return self.prng.randbytes(size)
158+
try:
159+
return self.prng.randbytes(size)
160+
except AttributeError: # randbytes is new in python 3.9
161+
return bytes(self.prng.randint(0, 255) for _ in range(size))
159162

160163

161164
@contextmanager

hypothesis-python/tests/conjecture/test_engine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def tf(data):
173173
except RecursionError:
174174
data.mark_interesting()
175175

176-
runner = ConjectureRunner(tf)
176+
runner = ConjectureRunner(tf, settings=settings(derandomize=True))
177177
runner.run()
178178
assert runner.exit_reason == ExitReason.finished
179179

0 commit comments

Comments
 (0)