| 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 |
given_booleans = given(st.booleans()) |
| 16 |
|
| 17 |
|
| 18 |
@given_booleans |
| 19 |
def test_has_an_arg_named_x(x): |
| 20 |
pass |
| 21 |
|
| 22 |
|
| 23 |
@given_booleans |
| 24 |
def test_has_an_arg_named_y(y): |
| 25 |
pass |
| 26 |
|
| 27 |
|
| 28 |
given_named_booleans = given(z=st.text()) |
| 29 |
|
| 30 |
|
| 31 |
def test_fail_independently(): |
| 32 |
@given_named_booleans |
| 33 |
def test_z1(z): |
| 34 |
raise AssertionError |
| 35 |
|
| 36 |
@given_named_booleans |
| 37 |
def test_z2(z): |
| 38 |
pass |
| 39 |
|
| 40 |
with pytest.raises(AssertionError): |
| 41 |
test_z1() |
| 42 |
|
| 43 |
test_z2() |