Debian Codegraph @

hypothesis-python/tests/numpy/test_deprecation.py

raw
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 warnings import catch_warnings
12
13 import pytest
14
15 from hypothesis.errors import HypothesisDeprecationWarning, InvalidArgument
16 from hypothesis.extra import numpy as nps
17
18 from tests.common.debug import check_can_generate_examples
19
20
21 def test_basic_indices_bad_min_dims_warns():
22 with pytest.warns(HypothesisDeprecationWarning), pytest.raises(InvalidArgument):
23 check_can_generate_examples(nps.basic_indices((3, 3, 3), min_dims=4))
24
25
26 def test_basic_indices_bad_max_dims_warns():
27 with pytest.warns(HypothesisDeprecationWarning):
28 check_can_generate_examples(nps.basic_indices((3, 3, 3), max_dims=4))
29
30
31 def test_basic_indices_default_max_dims_does_not_warn():
32 with catch_warnings(record=True) as record:
33 check_can_generate_examples(nps.basic_indices((3, 3, 3)))
34 check_can_generate_examples(nps.basic_indices((3, 3, 3), allow_newaxis=True))
35 assert len(record) == 0