From c6597ac89f3690a44df27fb71885fc1490e82be5 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Thu, 9 Jun 2022 11:15:04 -0700 Subject: TST: Improve testing setup by introducing a new `weak_promotion` fixture Unfortunately, this shows that the rational tests are still broken a bit. --- numpy/conftest.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'numpy/conftest.py') diff --git a/numpy/conftest.py b/numpy/conftest.py index fd5fdd77d..8aa6587ee 100644 --- a/numpy/conftest.py +++ b/numpy/conftest.py @@ -117,3 +117,20 @@ def add_np(doctest_namespace): @pytest.fixture(autouse=True) def env_setup(monkeypatch): monkeypatch.setenv('PYTHONHASHSEED', '0') + + +@pytest.fixture(params=[True, False]) +def weak_promotion(request): + """ + Fixture to ensure "legacy" promotion state or change it to use the new + weak promotion (plus warning). `old_promotion` should be used as a + parameter in the function. + """ + state = numpy._get_promotion_state() + if request.param: + numpy._set_promotion_state("weak_and_warn") + else: + numpy._set_promotion_state("legacy") + + yield request.param + numpy._set_promotion_state(state) -- cgit v1.2.1