mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-02 01:40:42 +00:00
Reorganized some test code
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
from . import test_wave_parsing
|
from . import test_wave_parsing
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
BIN
tests/test_files/rf64/Testfile_SEQ_RF64 Big.wav.gz
Executable file
BIN
tests/test_files/rf64/Testfile_SEQ_RF64 Big.wav.gz
Executable file
Binary file not shown.
Binary file not shown.
@@ -1,42 +1,11 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
import subprocess
|
|
||||||
from subprocess import PIPE
|
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from .utils import all_files, ffprobe
|
||||||
|
|
||||||
import wavinfo
|
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]
|
|
||||||
if output:
|
|
||||||
output_str = output.decode('utf-8')
|
|
||||||
return json.loads(output_str)
|
|
||||||
else:
|
|
||||||
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):
|
class TestWaveInfo(TestCase):
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
|
|||||||
39
tests/utils.py
Normal file
39
tests/utils.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import os.path
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
from subprocess import PIPE
|
||||||
|
import json
|
||||||
|
|
||||||
|
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]
|
||||||
|
if output:
|
||||||
|
output_str = output.decode('utf-8')
|
||||||
|
return json.loads(output_str)
|
||||||
|
else:
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user