| 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 strategies as st |
| 14 |
from hypothesis.errors import InvalidArgument |
| 15 |
|
| 16 |
|
| 17 |
def test_no_args(): |
| 18 |
assert st.text() is st.text() |
| 19 |
|
| 20 |
|
| 21 |
def test_tuple_lengths(): |
| 22 |
assert st.tuples(st.integers()) is st.tuples(st.integers()) |
| 23 |
assert st.tuples(st.integers()) is not st.tuples(st.integers(), st.integers()) |
| 24 |
|
| 25 |
|
| 26 |
def test_values(): |
| 27 |
assert st.integers() is not st.integers(min_value=1) |
| 28 |
|
| 29 |
|
| 30 |
def test_alphabet_key(): |
| 31 |
assert st.text(alphabet="abcs") is st.text(alphabet="abcs") |
| 32 |
|
| 33 |
|
| 34 |
def test_does_not_error_on_unhashable_posarg(): |
| 35 |
st.text(["a", "b", "c"]) |
| 36 |
|
| 37 |
|
| 38 |
def test_does_not_error_on_unhashable_kwarg(): |
| 39 |
with pytest.raises(InvalidArgument): |
| 40 |
st.builds(lambda alphabet: 1, alphabet=["a", "b", "c"]).validate() |
| 41 |
|
| 42 |
|
| 43 |
def test_caches_floats_sensitively(): |
| 44 |
assert st.floats(min_value=0.0) is st.floats(min_value=0.0) |
| 45 |
assert st.floats(min_value=0.0) is not st.floats(min_value=0) |
| 46 |
assert st.floats(min_value=0.0) is not st.floats(min_value=-0.0) |