summaryrefslogtreecommitdiff
path: root/numpy/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/conftest.py')
-rw-r--r--numpy/conftest.py17
1 files changed, 17 insertions, 0 deletions
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)