From cc94c1a06240b277a49e898836d3e239b5d7f016 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" <h.vetinari@gmx.com>
Date: Thu, 5 Aug 2021 19:54:33 +0200
Subject: [PATCH 2/4] parametrize test_wavfile.test_write_roundtrip

---
 scipy/io/tests/test_wavfile.py | 47 +++++++++++++++-------------------
 1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/scipy/io/tests/test_wavfile.py b/scipy/io/tests/test_wavfile.py
index 712ba4fd8..ddf682c15 100644
--- a/scipy/io/tests/test_wavfile.py
+++ b/scipy/io/tests/test_wavfile.py
@@ -370,7 +370,18 @@ def test_read_inconsistent_header():
                 wavfile.read(fp, mmap=mmap)
 
 
-def _check_roundtrip(realfile, rate, dtype, channels, tmpdir):
+# signed 8-bit integer PCM is not allowed
+# unsigned > 8-bit integer PCM is not allowed
+# 8- or 16-bit float PCM is not expected
+# g and q are platform-dependent, so not included
+@pytest.mark.parametrize("dt_str", ["<i2", "<i4", "<i8", "<f4", "<f8",
+                                    ">i2", ">i4", ">i8", ">f4", ">f8", '|u1'])
+@pytest.mark.parametrize("channels", [1, 2, 5])
+@pytest.mark.parametrize("rate", [8000, 32000])
+@pytest.mark.parametrize("mmap", [False, True])
+@pytest.mark.parametrize("realfile", [False, True])
+def test_write_roundtrip(realfile, mmap, rate, channels, dt_str, tmpdir):
+    dtype = np.dtype(dt_str)
     if realfile:
         tmpfile = str(tmpdir.join('temp.wav'))
     else:
@@ -386,30 +397,14 @@ def _check_roundtrip(realfile, rate, dtype, channels, tmpdir):
 
     wavfile.write(tmpfile, rate, data)
 
-    for mmap in [False, True]:
-        rate2, data2 = wavfile.read(tmpfile, mmap=mmap)
+    rate2, data2 = wavfile.read(tmpfile, mmap=mmap)
 
-        assert_equal(rate, rate2)
-        assert_(data2.dtype.byteorder in ('<', '=', '|'), msg=data2.dtype)
-        assert_array_equal(data, data2)
-        # also test writing (gh-12176)
-        if realfile:
+    assert_equal(rate, rate2)
+    assert_(data2.dtype.byteorder in ('<', '=', '|'), msg=data2.dtype)
+    assert_array_equal(data, data2)
+    # also test writing (gh-12176)
+    if realfile:
+        data2[0] = 0
+    else:
+        with pytest.raises(ValueError, match='read-only'):
             data2[0] = 0
-        else:
-            with pytest.raises(ValueError, match='read-only'):
-                data2[0] = 0
-
-
-def test_write_roundtrip(tmpdir):
-    for realfile in (False, True):
-        # signed 8-bit integer PCM is not allowed
-        # unsigned > 8-bit integer PCM is not allowed
-        # 8- or 16-bit float PCM is not expected
-        # g and q are platform-dependent, so not included
-        for dt_str in {'|u1',
-                       '<i2', '<i4', '<i8', '<f4', '<f8',
-                       '>i2', '>i4', '>i8', '>f4', '>f8'}:
-            for rate in (8000, 32000):
-                for channels in (1, 2, 5):
-                    dt = np.dtype(dt_str)
-                    _check_roundtrip(realfile, rate, dt, channels, tmpdir)
-- 
2.32.0.windows.2

