diff --git a/loopback_required.patch b/loopback_required.patch new file mode 100644 index 0000000..f706bcb --- /dev/null +++ b/loopback_required.patch @@ -0,0 +1,144 @@ +--- + tests/__init__.py | 3 +++ + tests/error_tests.py | 5 +++++ + tests/pyaudio_tests.py | 11 +++++++++++ + 3 files changed, 19 insertions(+) + +--- /dev/null ++++ b/tests/__init__.py +@@ -0,0 +1,3 @@ ++import os ++ ++HARDWARE = 'HW_REQUIRED' in os.environ +--- a/tests/error_tests.py ++++ b/tests/error_tests.py +@@ -3,6 +3,7 @@ import time + import unittest + + import pyaudio ++from tests import HARDWARE + + class PyAudioErrorTests(unittest.TestCase): + def setUp(self): +@@ -55,6 +56,7 @@ class PyAudioErrorTests(unittest.TestCas + input=True) + stream.write('foo') + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_error_negative_frames(self): + with self.assertRaises(ValueError): + stream = self.p.open(channels=1, +@@ -63,6 +65,7 @@ class PyAudioErrorTests(unittest.TestCas + input=True) + stream.read(-1) + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_invalid_attr_on_closed_stream(self): + stream = self.p.open(channels=1, + rate=44100, +@@ -81,6 +84,7 @@ class PyAudioErrorTests(unittest.TestCas + with self.assertRaises(ValueError): + self.p.is_format_supported(8000, 0, -1, pyaudio.paInt16) + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_write_underflow_exception(self): + stream = self.p.open(channels=1, + rate=44100, +@@ -100,6 +104,7 @@ class PyAudioErrorTests(unittest.TestCas + self.assertEqual(err.exception.errno, pyaudio.paOutputUnderflowed) + self.assertEqual(err.exception.strerror, 'Output underflowed') + ++ @unittest.skipIf(HARDWARE, 'Loopback hardware required.') + def test_read_overflow_exception(self): + stream = self.p.open(channels=1, + rate=44100, +--- a/tests/pyaudio_tests.py ++++ b/tests/pyaudio_tests.py +@@ -22,6 +22,7 @@ import sys + import numpy + + import pyaudio ++from tests import HARDWARE + + DUMP_CAPTURE=False + +@@ -71,6 +72,7 @@ class PyAudioTests(unittest.TestCase): + + return input_idx, output_idx + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_system_info(self): + """Basic system info tests""" + self.assertTrue(self.p.get_host_api_count() > 0) +@@ -78,6 +80,7 @@ class PyAudioTests(unittest.TestCase): + api_info = self.p.get_host_api_info_by_index(0) + self.assertTrue(len(api_info.items()) > 0) + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_input_output_blocking(self): + """Test blocking-based record and playback.""" + rate = 44100 # frames per second +@@ -138,6 +141,7 @@ class PyAudioTests(unittest.TestCase): + test_signal, + len(freqs)) + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_input_output_callback(self): + """Test callback-based record and playback.""" + rate = 44100 # frames per second +@@ -207,6 +211,7 @@ class PyAudioTests(unittest.TestCase): + test_signal, + len(freqs)) + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_device_lock_gil_order(self): + """Ensure no deadlock between Pa_{Open,Start,Stop}Stream and GIL.""" + # This test targets OSX/macOS CoreAudio, which seems to use +@@ -262,6 +267,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_stream_state_gil(self): + """Ensure no deadlock between Pa_IsStream{Active,Stopped} and GIL.""" + rate = 44100 # frames per second +@@ -322,6 +328,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_time_gil(self): + """Ensure no deadlock between PA_GetStreamTime and GIL.""" + rate = 44100 # frames per second +@@ -376,6 +383,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_cpuload_gil(self): + """Ensure no deadlock between Pa_GetStreamCpuLoad and GIL.""" + rate = 44100 # frames per second +@@ -430,6 +438,7 @@ class PyAudioTests(unittest.TestCase): + in_stream.stop_stream() + out_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_write_available_gil(self): + """Ensure no deadlock between Pa_GetStreamWriteAvailable and GIL.""" + rate = 44100 # frames per second +@@ -477,6 +486,7 @@ class PyAudioTests(unittest.TestCase): + time.sleep(0.1) + in_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_get_stream_read_available_gil(self): + """Ensure no deadlock between Pa_GetStreamReadAvailable and GIL.""" + rate = 44100 # frames per second +@@ -524,6 +534,7 @@ class PyAudioTests(unittest.TestCase): + time.sleep(0.1) + in_stream.stop_stream() + ++ @unittest.skipIf(HARDWARE, 'Loopback device required.') + def test_terminate_gil(self): + """Ensure no deadlock between Pa_Terminate and GIL.""" + rate = 44100 # frames per second diff --git a/python-PyAudio.changes b/python-PyAudio.changes index 28e7fb1..feff164 100644 --- a/python-PyAudio.changes +++ b/python-PyAudio.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Feb 7 14:14:04 UTC 2022 - Matej Cepl + +- Add loopback_required.patch which allows skipping over tests + requiring special hardware without pytest. The issue reported + upstream by email. + ------------------------------------------------------------------- Thu Nov 7 15:06:44 UTC 2019 - Matej Cepl diff --git a/python-PyAudio.spec b/python-PyAudio.spec index 3e98b8e..c853fee 100644 --- a/python-PyAudio.spec +++ b/python-PyAudio.spec @@ -1,7 +1,7 @@ # # spec file for package python-PyAudio # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} -%bcond_with test +%bcond_without test Name: python-PyAudio Version: 0.2.11 Release: 0 @@ -25,13 +25,15 @@ Summary: Python Bindings for PortAudio v19 License: MIT URL: https://people.csail.mit.edu/hubert/pyaudio/ Source: https://files.pythonhosted.org/packages/source/P/PyAudio/PyAudio-%{version}.tar.gz +# PATCH-FIX-UPSTREAM loopback_required.patch mcepl@suse.com +# Mark tests requiring specific hardware as such +Patch0: loopback_required.patch BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: portaudio-devel BuildRequires: python-rpm-macros %if %{with test} -BuildRequires: %{python_module nose} BuildRequires: %{python_module numpy} BuildRequires: alsa %endif @@ -44,6 +46,7 @@ of platforms (e.g., GNU/Linux, Microsoft Windows, and Mac OS X). %prep %setup -q -n PyAudio-%{version} +%autopatch -p1 %build export CFLAGS="%{optflags} -fno-strict-aliasing" @@ -55,11 +58,9 @@ export CFLAGS="%{optflags} -fno-strict-aliasing" %if %{with test} %check -pushd tests -%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitearch} -$python -B -m nose ./*.py -} -popd +# report send to hubert@mit.edu +export HW_REQUIRED=1 +%pyunittest_arch discover -p '*.py' -v -s tests %endif %files %{python_files}