| 1 |
# This file is part of Hypothesis, which may be found at |
| 2 |
# https://github.com/HypothesisWorks/hypothesis/ |
| 3 |
# |
| 4 |
# Copyright the Hypothesis Authors. |
| 5 |
# Individual contributors are listed in AUTHORS.rst and the git log. |
| 6 |
# |
| 7 |
# This Source Code Form is subject to the terms of the Mozilla Public License, |
| 8 |
# v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 9 |
# obtain one at https://mozilla.org/MPL/2.0/. |
| 10 |
|
| 11 |
import pytest |
| 12 |
|
| 13 |
from hypothesis import given, strategies as st |
| 14 |
|
| 15 |
|
| 16 |
@st.composite |
| 17 |
def strat(draw, x=0, /): |
| 18 |
return draw(st.integers(min_value=x)) |
| 19 |
|
| 20 |
|
| 21 |
@given(st.data(), st.integers()) |
| 22 |
def test_composite_with_posonly_args(data, min_value): |
| 23 |
v = data.draw(strat(min_value)) |
| 24 |
assert min_value <= v |
| 25 |
|
| 26 |
|
| 27 |
def test_preserves_signature(): |
| 28 |
with pytest.raises(TypeError): |
| 29 |
strat(x=1) |
| 30 |
|
| 31 |
|
| 32 |
def test_builds_real_pos_only(): |
| 33 |
with pytest.raises(TypeError): |
| 34 |
st.builds() # requires a target! |