This commit is contained in:
Jamie Hardt
2019-01-05 12:37:32 -08:00
2 changed files with 16 additions and 21 deletions

View File

@@ -12,10 +12,12 @@ before_install:
- "sudo add-apt-repository universe"
- "sudo apt-get install -y ffmpeg"
- "pip install coverage"
- "pip install codecov"
# - "pip install coverage==4.4"
- "pip install pytest-cov==2.5.0"
- "pip install python-coveralls"
install:
- "pip install setuptools"
after_success:
- "codecov -t"
- coveralls

View File

@@ -10,16 +10,13 @@ import wavinfo
FFPROBE='ffprobe'
def ffprobe(path):
arguments = [ FFPROBE , "-of", "json" , "-show_format", "-show_streams", path ]
if int(sys.version[0]) < 3:
process = subprocess.Popen(arguments, stdout=PIPE)
process.wait()
if process.returncode == 0:
output = process.communicate()[0]
output = process.communicate()[0]
if output:
output_str = output.decode('utf-8')
return json.loads(output_str)
@@ -27,31 +24,28 @@ def ffprobe(path):
return None
else:
process = subprocess.run(arguments, stdin=None, stdout=PIPE, stderr=PIPE)
if process.returncode == 0:
output_str = process.stdout.decode('utf-8')
return json.loads(output_str)
else:
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)
class TestWaveInfo(TestCase):
def all_files(self):
for dirpath, dirnames, filenames in os.walk('tests/test_files'):
for filename in filenames:
name, ext = os.path.splitext(filename)
if ext in ['.wav','.WAV']:
yield os.path.join(dirpath, filename)
def test_sanity(self):
for wav_file in self.all_files():
for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file)
self.assertTrue(info is not None)
def test_fmt_against_ffprobe(self):
for wav_file in self.all_files():
for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file)
ffprobe_info = ffprobe(wav_file)
@@ -67,14 +61,13 @@ class TestWaveInfo(TestCase):
self.assertEqual( info.fmt.byte_rate , byte_rate )
def test_data_against_ffprobe(self):
for wav_file in self.all_files():
for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file)
ffprobe_info = ffprobe(wav_file)
self.assertEqual( info.data.frame_count, int(ffprobe_info['streams'][0]['duration_ts'] ))
def test_bext_against_ffprobe(self):
for wav_file in self.all_files():
for wav_file in all_files():
info = wavinfo.WavInfoReader(wav_file)
ffprobe_info = ffprobe(wav_file)
if info.bext:
@@ -106,7 +99,7 @@ class TestWaveInfo(TestCase):
'tape': '18Y12M31', 'family_uid': 'USSDVGR1112089007124001008206300'},
}
for wav_file in self.all_files():
for wav_file in all_files():
basename = os.path.basename(wav_file)
if basename in expected:
info = wavinfo.WavInfoReader(wav_file)