Skip to content

Commit

Permalink
More travis test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joextodd committed Apr 8, 2018
1 parent 4bff270 commit 5fffb48
Showing 1 changed file with 11 additions and 29 deletions.
40 changes: 11 additions & 29 deletions tests/test_pysoundio.py
Expand Up @@ -3,7 +3,6 @@
PySoundIo Test Suite
"""
import os
import unittest
import pysoundio
import _soundiox
Expand Down Expand Up @@ -32,8 +31,6 @@ def setUp(self):
self.callback_called = False
self.error_callback_called = False

self.is_travis = 'TRAVIS' in os.environ

# - Device API

def test_backend_count(self):
Expand Down Expand Up @@ -107,6 +104,11 @@ def test_bytes_per_second(self):

# - Input Stream API

def fill_input_buffer(self):
data = bytearray(b'\x00' * 4096 * 8)
_soundiox.ring_buffer_write_ptr(self.sio.input_buffer, data, len(data))
_soundiox.ring_buffer_advance_write_ptr(self.sio.input_buffer, len(data))

def test__create_input_ring_buffer(self):
capacity = 44100 * 8
self.assertIsNotNone(self.sio._create_input_ring_buffer(capacity))
Expand All @@ -115,25 +117,19 @@ def test__create_input_stream(self):
self.sio.get_default_input_device()
stream = self.sio._create_input_stream()
self.assertIsNotNone(stream)
self.sio.input_stream = None

def test__create_input_stream_blocksize(self):
self.sio.block_size = 4096
self.sio.get_default_input_device()
stream = self.sio._create_input_stream()
self.assertIsNotNone(stream)
self.sio.input_stream = None

def test__open_input_stream(self):
self.sio.get_default_input_device()
self.sio._create_input_stream()
self.sio._open_input_stream()

def test_get_input_latency(self):
self.sio.start_input_stream(
sample_rate=44100,
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.fill_input_buffer()
self.assertIsInstance(self.sio.get_input_latency(0.2), int)

def overflow_callback(self, stream):
Expand All @@ -157,22 +153,24 @@ def test_start_input_stream(self):
sample_rate=44100,
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.fill_input_buffer()
self.assertIsNotNone(self.sio.input_stream)

def test_pause_input_stream(self):
self.sio.start_input_stream(
sample_rate=44100,
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.fill_input_buffer()
self.sio.pause_input_stream(True)
self.sio.input_stream = None

def test_start_input_stream_device(self):
self.sio.start_input_stream(
device_id=0,
sample_rate=44100,
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.fill_input_buffer()
self.assertIsNotNone(self.sio.input_stream)

def test_start_input_invalid_rate(self):
Expand All @@ -186,6 +184,7 @@ def test_start_input_default_rate(self):
self.sio.start_input_stream(
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.fill_input_buffer()
self.assertIsNotNone(self.sio.input_stream)
self.assertIsInstance(self.sio.sample_rate, int)

Expand All @@ -200,43 +199,32 @@ def test_start_input_default_format(self):
self.sio.start_input_stream(
sample_rate=44100,
channels=2)
self.fill_input_buffer()
self.assertIsNotNone(self.sio.input_stream)
self.assertIsInstance(self.sio.format, int)

# -- Output Stream API

def fill_output_buffer(self):
self.sio._create_output_ring_buffer(44100 * 8)
data = bytearray(b'\x00' * 4096 * 8)
_soundiox.ring_buffer_write_ptr(self.sio.output_buffer, data, len(data))
_soundiox.ring_buffer_advance_write_ptr(self.sio.output_buffer, len(data))

def test__create_output_ring_buffer(self):
capacity = 44100 * 8
self.assertIsNotNone(self.sio._create_output_ring_buffer(capacity))

def test__create_output_stream(self):
self.sio.get_default_output_device()
self.fill_output_buffer()
stream = self.sio._create_output_stream()
self.assertIsNotNone(stream)
self.sio.output_stream = None

def test__create_output_stream_blocksize(self):
self.sio.block_size = 4096
self.sio.get_default_output_device()
self.fill_output_buffer()
stream = self.sio._create_output_stream()
self.assertIsNotNone(stream)
self.sio.output_stream = None

def test__open_output_stream(self):
self.sio.get_default_output_device()
self.fill_output_buffer()
self.sio._create_output_stream()
self.sio._open_output_stream()
self.assertIsNotNone(self.sio.block_size)
self.sio.output_stream = None

def test_clear_output_buffer(self):
capacity = 44100 * 8
Expand All @@ -257,23 +245,20 @@ def test_get_output_latency(self):
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.assertIsInstance(self.sio.get_output_latency(0.2), int)
self.sio.output_stream = None

def test_pause_output_stream(self):
self.sio.start_output_stream(
sample_rate=44100,
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.sio.pause_output_stream(True)
self.sio.output_stream = None

def test_start_output_stream(self):
self.sio.start_output_stream(
sample_rate=44100,
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.assertIsNotNone(self.sio.output_stream)
self.sio.output_stream = None

def test_start_output_stream_device(self):
self.sio.start_output_stream(
Expand All @@ -282,7 +267,6 @@ def test_start_output_stream_device(self):
dtype=pysoundio.SoundIoFormatFloat32LE,
channels=2)
self.assertIsNotNone(self.sio.output_stream)
self.sio.output_stream = None

def test_start_output_invalid_rate(self):
with self.assertRaises(pysoundio.PySoundIoError):
Expand All @@ -297,7 +281,6 @@ def test_start_output_default_rate(self):
channels=2)
self.assertIsNotNone(self.sio.output_stream)
self.assertIsInstance(self.sio.sample_rate, int)
self.sio.output_stream = None

def test_start_output_invalid_format(self):
with self.assertRaises(pysoundio.PySoundIoError):
Expand All @@ -312,7 +295,6 @@ def test_start_output_default_format(self):
channels=2)
self.assertIsNotNone(self.sio.output_stream)
self.assertIsInstance(self.sio.format, int)
self.sio.output_stream = None


class TestInputProcessing(unittest.TestCase):
Expand Down

0 comments on commit 5fffb48

Please sign in to comment.