14
0

- Add loopback_required.patch which allows skipping over tests

requiring special hardware without pytest. The issue reported
  upstream by email.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PyAudio?expand=0&rev=12
This commit is contained in:
2022-02-07 14:15:00 +00:00
committed by Git OBS Bridge
parent 2dbd93b29e
commit 185a902fb4
3 changed files with 160 additions and 8 deletions

144
loopback_required.patch Normal file
View File

@@ -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

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Feb 7 14:14:04 UTC 2022 - Matej Cepl <mcepl@suse.com>
- 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 <mcepl@suse.com> Thu Nov 7 15:06:44 UTC 2019 - Matej Cepl <mcepl@suse.com>

View File

@@ -1,7 +1,7 @@
# #
# spec file for package python-PyAudio # 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 # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}} %{?!python_module:%define python_module() python-%{**} python3-%{**}}
%bcond_with test %bcond_without test
Name: python-PyAudio Name: python-PyAudio
Version: 0.2.11 Version: 0.2.11
Release: 0 Release: 0
@@ -25,13 +25,15 @@ Summary: Python Bindings for PortAudio v19
License: MIT License: MIT
URL: https://people.csail.mit.edu/hubert/pyaudio/ URL: https://people.csail.mit.edu/hubert/pyaudio/
Source: https://files.pythonhosted.org/packages/source/P/PyAudio/PyAudio-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/P/PyAudio/PyAudio-%{version}.tar.gz
# PATCH-FIX-UPSTREAM loopback_required.patch bsc#[0-9]+ mcepl@suse.com
# Mark tests requiring specific hardware as such
Patch0: loopback_required.patch
BuildRequires: %{python_module devel} BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: portaudio-devel BuildRequires: portaudio-devel
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
%if %{with test} %if %{with test}
BuildRequires: %{python_module nose}
BuildRequires: %{python_module numpy} BuildRequires: %{python_module numpy}
BuildRequires: alsa BuildRequires: alsa
%endif %endif
@@ -44,6 +46,7 @@ of platforms (e.g., GNU/Linux, Microsoft Windows, and Mac OS X).
%prep %prep
%setup -q -n PyAudio-%{version} %setup -q -n PyAudio-%{version}
%autopatch -p1
%build %build
export CFLAGS="%{optflags} -fno-strict-aliasing" export CFLAGS="%{optflags} -fno-strict-aliasing"
@@ -55,11 +58,9 @@ export CFLAGS="%{optflags} -fno-strict-aliasing"
%if %{with test} %if %{with test}
%check %check
pushd tests # report send to hubert@mit.edu
%{python_expand export PYTHONPATH=%{buildroot}%{$python_sitearch} export HW_REQUIRED=1
$python -B -m nose ./*.py %pyunittest_arch discover -p '*.py' -v -s tests
}
popd
%endif %endif
%files %{python_files} %files %{python_files}