summaryrefslogtreecommitdiff
path: root/numpy/conftest.py
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2022-06-09 11:15:04 -0700
committerSebastian Berg <sebastian@sipsolutions.net>2022-06-15 11:42:02 -0700
commitc6597ac89f3690a44df27fb71885fc1490e82be5 (patch)
treef8b35853f89c8556ae47794b5ed37a957dc0bf04 /numpy/conftest.py
parentf0a1af6e3dcc080dc5c120fc99b261b237bbd66c (diff)
downloadnumpy-c6597ac89f3690a44df27fb71885fc1490e82be5.tar.gz
TST: Improve testing setup by introducing a new `weak_promotion` fixture
Unfortunately, this shows that the rational tests are still broken a bit.
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)