mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-01 17:30:41 +00:00
Merge branch 'master' of https://github.com/iluvcapra/wavinfo
This commit is contained in:
@@ -12,10 +12,12 @@ before_install:
|
|||||||
- "sudo add-apt-repository universe"
|
- "sudo add-apt-repository universe"
|
||||||
- "sudo apt-get install -y ffmpeg"
|
- "sudo apt-get install -y ffmpeg"
|
||||||
- "pip install coverage"
|
- "pip install coverage"
|
||||||
|
- "pip install codecov"
|
||||||
# - "pip install coverage==4.4"
|
# - "pip install coverage==4.4"
|
||||||
- "pip install pytest-cov==2.5.0"
|
- "pip install pytest-cov==2.5.0"
|
||||||
- "pip install python-coveralls"
|
- "pip install python-coveralls"
|
||||||
install:
|
install:
|
||||||
- "pip install setuptools"
|
- "pip install setuptools"
|
||||||
after_success:
|
after_success:
|
||||||
|
- "codecov -t"
|
||||||
- coveralls
|
- coveralls
|
||||||
|
|||||||
@@ -10,11 +10,8 @@ import wavinfo
|
|||||||
|
|
||||||
FFPROBE='ffprobe'
|
FFPROBE='ffprobe'
|
||||||
|
|
||||||
|
|
||||||
def ffprobe(path):
|
def ffprobe(path):
|
||||||
|
|
||||||
arguments = [ FFPROBE , "-of", "json" , "-show_format", "-show_streams", path ]
|
arguments = [ FFPROBE , "-of", "json" , "-show_format", "-show_streams", path ]
|
||||||
|
|
||||||
if int(sys.version[0]) < 3:
|
if int(sys.version[0]) < 3:
|
||||||
process = subprocess.Popen(arguments, stdout=PIPE)
|
process = subprocess.Popen(arguments, stdout=PIPE)
|
||||||
process.wait()
|
process.wait()
|
||||||
@@ -27,31 +24,28 @@ def ffprobe(path):
|
|||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
process = subprocess.run(arguments, stdin=None, stdout=PIPE, stderr=PIPE)
|
process = subprocess.run(arguments, stdin=None, stdout=PIPE, stderr=PIPE)
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
output_str = process.stdout.decode('utf-8')
|
output_str = process.stdout.decode('utf-8')
|
||||||
return json.loads(output_str)
|
return json.loads(output_str)
|
||||||
else:
|
else:
|
||||||
return None
|
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):
|
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):
|
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)
|
||||||
|
|
||||||
@@ -67,14 +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:
|
||||||
@@ -106,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)
|
||||||
|
|||||||
Reference in New Issue
Block a user