Update test_wave_parsing.py

This commit is contained in:
Jamie Hardt
2019-01-05 12:34:54 -08:00
committed by GitHub
parent 7992640fb8
commit 12de7b078f

View File

@@ -30,21 +30,22 @@ def ffprobe(path):
else: else:
return None return None
class TestWaveInfo(TestCase):
def all_files(self):
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)
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)
class TestWaveInfo(TestCase):
def test_sanity(self): def test_sanity(self):
for wav_file in self.all_files(): for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file) info = wavinfo.WavInfoReader(wav_file)
self.assertTrue(info is not None) self.assertTrue(info is not None)
def test_fmt_against_ffprobe(self): def test_fmt_against_ffprobe(self):
for wav_file in self.all_files(): for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file) info = wavinfo.WavInfoReader(wav_file)
ffprobe_info = ffprobe(wav_file) ffprobe_info = ffprobe(wav_file)
@@ -60,13 +61,13 @@ class TestWaveInfo(TestCase):
self.assertEqual( info.fmt.byte_rate , byte_rate ) self.assertEqual( info.fmt.byte_rate , byte_rate )
def test_data_against_ffprobe(self): def test_data_against_ffprobe(self):
for wav_file in self.all_files(): for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file) info = wavinfo.WavInfoReader(wav_file)
ffprobe_info = ffprobe(wav_file) ffprobe_info = ffprobe(wav_file)
self.assertEqual( info.data.frame_count, int(ffprobe_info['streams'][0]['duration_ts'] )) self.assertEqual( info.data.frame_count, int(ffprobe_info['streams'][0]['duration_ts'] ))
def test_bext_against_ffprobe(self): def test_bext_against_ffprobe(self):
for wav_file in self.all_files(): for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file) info = wavinfo.WavInfoReader(wav_file)
ffprobe_info = ffprobe(wav_file) ffprobe_info = ffprobe(wav_file)
if info.bext: if info.bext:
@@ -98,7 +99,7 @@ class TestWaveInfo(TestCase):
'tape': '18Y12M31', 'family_uid': 'USSDVGR1112089007124001008206300'}, 'tape': '18Y12M31', 'family_uid': 'USSDVGR1112089007124001008206300'},
} }
for wav_file in self.all_files(): for wav_file in all_files():
basename = os.path.basename(wav_file) basename = os.path.basename(wav_file)
if basename in expected: if basename in expected:
info = wavinfo.WavInfoReader(wav_file) info = wavinfo.WavInfoReader(wav_file)