| 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 |
from hypothesis import assume, given, strategies as st |
| 12 |
from hypothesis.strategies._internal.lazy import unwrap_strategies |
| 13 |
|
| 14 |
from tests.common.debug import assert_no_examples |
| 15 |
|
| 16 |
|
| 17 |
@given(st.integers().map(lambda x: assume(x % 3 != 0) and x)) |
| 18 |
def test_can_assume_in_map(x): |
| 19 |
assert x % 3 != 0 |
| 20 |
|
| 21 |
|
| 22 |
def test_assume_in_just_raises_immediately(): |
| 23 |
assert_no_examples(st.just(1).map(lambda x: assume(x == 2))) |
| 24 |
|
| 25 |
|
| 26 |
def test_identity_map_is_noop(): |
| 27 |
s = unwrap_strategies(st.integers()) |
| 28 |
assert s.map(lambda x: x) is s |