Skip to content

Commit 6748fae

Browse files
committed
added pyaudio_mock wip #84
1 parent ba1d59c commit 6748fae

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

test/audio_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import unittest
22
import os
33
import test.pyaudio_mock
4-
4+
import pyaudio
55
import audio
66

77
FILENAME = "test.wav"
88

99
class AudioTest(unittest.TestCase):
1010
def setUp(self):
11-
piaudio.PyAudio = test.pyaudio_mock.PyAudioMock
11+
pyaudio.PyAudio = test.pyaudio_mock.PyAudioMock
1212
self.audio = audio.Audio.get_instance()
1313

1414
def tearDown(self):

test/pyaudio_mock.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import unittest.mock
2+
import time
3+
import io
4+
import logging
5+
import numpy
6+
7+
logger = logging.getLogger()
8+
9+
class PyAudioMock(object):
10+
"""Implements PyAudio mock class
11+
PyAudio is the library used to access the integrated audio output and external audio source (microphone)
12+
"""
13+
14+
def __init__(self):
15+
pass
16+
17+
def open(self, format, channels, rate, frames_per_buffer, stream_callback):
18+
return self
19+
20+
def stop_stream(self):
21+
pass
22+
23+
def close(self):
24+
pass
25+
26+
def terminate(self):
27+
pass
28+
29+
def get_sample_size(format):
30+
return format * 16
31+

0 commit comments

Comments
 (0)