From 9c0e25ad88f49e340014a9b53bef0b23deb7c385 Mon Sep 17 00:00:00 2001
From: Matti Picus <matti.picus@gmail.com>
Date: Mon, 25 Jul 2022 22:34:45 +0300
Subject: [PATCH 2/2] test fixes for pypy

---
 scipy/sparse/tests/test_construct.py |  4 ++--
 scipy/stats/tests/test_sampling.py   | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/scipy/sparse/tests/test_construct.py b/scipy/sparse/tests/test_construct.py
index cfc9d0a06..9fc46ae05 100644
--- a/scipy/sparse/tests/test_construct.py
+++ b/scipy/sparse/tests/test_construct.py
@@ -421,7 +421,7 @@ class TestConstructUtils:
 
         with assert_raises(ValueError) as excinfo:
             construct.bmat([[A.tocsc()], [B.tocsc()]])
-        excinfo.match(r'Mismatching dimensions along axis 1: {1, 2}')
+        excinfo.match(r'Mismatching dimensions along axis 1: {[12], [12]}')
 
         with assert_raises(ValueError) as excinfo:
             construct.bmat([[A, C]])
@@ -429,7 +429,7 @@ class TestConstructUtils:
 
         with assert_raises(ValueError) as excinfo:
             construct.bmat([[A.tocsr(), C.tocsr()]])
-        excinfo.match(r'Mismatching dimensions along axis 0: {1, 2}')
+        excinfo.match(r'Mismatching dimensions along axis 0: {[12], [12]}')
 
         with assert_raises(ValueError) as excinfo:
             construct.bmat([[A.tocsc(), C.tocsc()]])
diff --git a/scipy/stats/tests/test_sampling.py b/scipy/stats/tests/test_sampling.py
index 5dffca4cd..37b7ac443 100644
--- a/scipy/stats/tests/test_sampling.py
+++ b/scipy/stats/tests/test_sampling.py
@@ -1,6 +1,7 @@
 import threading
 import pickle
 import pytest
+import sys
 from copy import deepcopy
 import numpy as np
 from numpy.testing import assert_allclose, assert_equal, suppress_warnings
@@ -46,6 +47,11 @@ all_methods = [
     ("SimpleRatioUniforms", {"dist": StandardNormal(), "mode": 0})
 ]
 
+if sys.implementation.name == 'pypy' and sys.implementation.version < (7, 3, 10):
+    # changed in PyPy for v7.3.10
+    floaterr = r"unsupported operand type for float\(\): 'list'"
+else:
+    floaterr = r"must be real number, not list"
 # Make sure an internal error occurs in UNU.RAN when invalid callbacks are
 # passed. Moreover, different generators throw different error messages.
 # So, in case of an `UNURANError`, we do not validate the error message.
@@ -53,7 +59,7 @@ bad_pdfs_common = [
     # Negative PDF
     (lambda x: -x, UNURANError, r"..."),
     # Returning wrong type
-    (lambda x: [], TypeError, r"must be real number, not list"),
+    (lambda x: [], TypeError, floaterr),
     # Undefined name inside the function
     (lambda x: foo, NameError, r"name 'foo' is not defined"),  # type: ignore[name-defined]  # noqa
     # Infinite value returned => Overflow error.
@@ -73,7 +79,7 @@ bad_dpdf_common = [
     # NaN value => internal error in UNU.RAN
     (lambda x: np.nan, UNURANError, r"..."),
     # Returning wrong type
-    (lambda x: [], TypeError, r"must be real number, not list"),
+    (lambda x: [], TypeError, floaterr),
     # Undefined name inside the function
     (lambda x: foo, NameError, r"name 'foo' is not defined"),  # type: ignore[name-defined]  # noqa
     # signature of dPDF wrong
-- 
2.37.0.windows.1

