| 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 |
@pytest.mark.parametrize("width", [32, 64, 128]) |
| 17 |
@pytest.mark.parametrize("keyword", ["min_magnitude", "max_magnitude"]) |
| 18 |
@given(data=st.data()) |
| 19 |
def test_magnitude_validates(width, keyword, data): |
| 20 |
# See https://github.com/HypothesisWorks/hypothesis/issues/3573 |
| 21 |
component_width = width / 2 |
| 22 |
magnitude = data.draw( |
| 23 |
# 1.8 is a known example that hasn't validated in the past |
| 24 |
st.floats(0, width=component_width) | st.just(1.8), |
| 25 |
label=keyword, |
| 26 |
) |
| 27 |
strat = st.complex_numbers(width=width, **{keyword: magnitude}) |
| 28 |
data.draw(strat) |