mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-02-15 06:25:38 +00:00
Add tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import unittest
|
||||
import wavinfo
|
||||
|
||||
|
||||
class TestWalk(unittest.TestCase):
|
||||
def test_walk_metadata(self):
|
||||
test_file = 'tests/test_files/protools/PT A101_4.A1.wav'
|
||||
|
||||
@@ -7,11 +7,13 @@ from .utils import all_files, ffprobe
|
||||
|
||||
import wavinfo
|
||||
|
||||
|
||||
class TestWaveInfo(TestCase):
|
||||
def test_sanity(self):
|
||||
for wav_file in all_files():
|
||||
info = wavinfo.WavInfoReader(wav_file)
|
||||
self.assertTrue(info is not None)
|
||||
self.assertEqual(info.__repr__(), 'WavInfoReader(%s, %s, %s)'.format(wav_file, 'latin_1', 'ascii'))
|
||||
self.assertIsNotNone(info)
|
||||
|
||||
def test_fmt_against_ffprobe(self):
|
||||
for wav_file in all_files():
|
||||
@@ -24,9 +26,8 @@ class TestWaveInfo(TestCase):
|
||||
|
||||
if info.fmt.audio_format == 1:
|
||||
self.assertTrue(ffprobe_info['streams'][0]['codec_name'].startswith('pcm'))
|
||||
byte_rate = int(ffprobe_info['streams'][0]['sample_rate']) \
|
||||
* ffprobe_info['streams'][0]['channels'] \
|
||||
* int(ffprobe_info['streams'][0]['bits_per_raw_sample']) / 8
|
||||
streams = ffprobe_info['streams'][0]
|
||||
byte_rate = int(streams['sample_rate']) * streams['channels'] * int(streams['bits_per_raw_sample']) / 8
|
||||
self.assertEqual(info.fmt.byte_rate, byte_rate)
|
||||
|
||||
def test_data_against_ffprobe(self):
|
||||
@@ -91,6 +92,4 @@ class TestWaveInfo(TestCase):
|
||||
for track in info.ixml.track_list:
|
||||
self.assertIsNotNone(track.channel_index)
|
||||
if basename == 'A101_4.WAV' and track.channel_index == '1':
|
||||
self.assertTrue(track.name == 'MKH516 A')
|
||||
|
||||
|
||||
self.assertEqual(track.name, 'MKH516 A')
|
||||
|
||||
@@ -8,5 +8,6 @@ from unittest import TestCase
|
||||
|
||||
import wavinfo
|
||||
|
||||
|
||||
class TestZoomF8(TestCase):
|
||||
pass
|
||||
|
||||
@@ -6,6 +6,7 @@ import json
|
||||
|
||||
FFPROBE = 'ffprobe'
|
||||
|
||||
|
||||
def ffprobe(path):
|
||||
arguments = [FFPROBE, "-of", "json", "-show_format", "-show_streams", path]
|
||||
if int(sys.version[0]) < 3:
|
||||
@@ -27,13 +28,9 @@ def ffprobe(path):
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def all_files():
|
||||
for dirpath, _, filenames in os.walk('tests/test_files'):
|
||||
for filename in filenames:
|
||||
_, ext = os.path.splitext(filename)
|
||||
if ext in ['.wav','.WAV']:
|
||||
yield os.path.join(dirpath, filename)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user