diff --git a/tests/__init__.py b/tests/__init__.py index 39ae5e6..f920153 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,2 +1,3 @@ from . import test_wave_parsing + diff --git a/tests/test_files_zipped/Pro_Tools_2019_RF64.wav.zip b/tests/test_files/rf64/Pro_Tools_2019_RF64.wav.gz similarity index 99% rename from tests/test_files_zipped/Pro_Tools_2019_RF64.wav.zip rename to tests/test_files/rf64/Pro_Tools_2019_RF64.wav.gz index 27ea902..2a91734 100644 Binary files a/tests/test_files_zipped/Pro_Tools_2019_RF64.wav.zip and b/tests/test_files/rf64/Pro_Tools_2019_RF64.wav.gz differ diff --git a/tests/test_files/rf64/Testfile_SEQ_RF64 Big.wav.gz b/tests/test_files/rf64/Testfile_SEQ_RF64 Big.wav.gz new file mode 100755 index 0000000..817ffe5 Binary files /dev/null and b/tests/test_files/rf64/Testfile_SEQ_RF64 Big.wav.gz differ diff --git a/tests/test_files_zipped/Testfile_SEQ_RF64.Big.zip b/tests/test_files_zipped/Testfile_SEQ_RF64.Big.zip deleted file mode 100644 index 8a4eebf..0000000 Binary files a/tests/test_files_zipped/Testfile_SEQ_RF64.Big.zip and /dev/null differ diff --git a/tests/test_wave_parsing.py b/tests/test_wave_parsing.py index ddbae38..583a69a 100644 --- a/tests/test_wave_parsing.py +++ b/tests/test_wave_parsing.py @@ -1,42 +1,11 @@ import os.path import sys -import json -import subprocess -from subprocess import PIPE from unittest import TestCase +from .utils import all_files, ffprobe + 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): def test_sanity(self): diff --git a/tests/utils.py b/tests/utils.py new file mode 100644 index 0000000..bc330f2 --- /dev/null +++ b/tests/utils.py @@ -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) + + +