diff --git a/tests/test_walk.py b/tests/test_walk.py new file mode 100644 index 0000000..8250f7d --- /dev/null +++ b/tests/test_walk.py @@ -0,0 +1,24 @@ +import unittest +import wavinfo + +class TestWalk(unittest.TestCase): + def test_walk_metadata(self): + test_file = 'tests/test_files/protools/PT A101_4.A1.wav' + info = wavinfo.WavInfoReader(test_file) + + tested_data , tested_format = False, False + for scope, key, value in info.walk(): + if scope == 'fmt': + if key == 'channel_count': + tested_format = True + self.assertEqual(value, 2) + if scope == 'data': + if key == 'frame_count': + tested_data = True + self.assertEqual(value, 144140) + + self.assertTrue(tested_data and tested_format) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_wave_parsing.py b/tests/test_wave_parsing.py index 18926a5..d821887 100644 --- a/tests/test_wave_parsing.py +++ b/tests/test_wave_parsing.py @@ -77,7 +77,7 @@ class TestWaveInfo(TestCase): } for wav_file in all_files(): - basename = os.path.basename(wav_file) + basename = os.path.basename(wav_file) if basename in expected: info = wavinfo.WavInfoReader(wav_file) e = expected[basename] diff --git a/wavinfo/wave_reader.py b/wavinfo/wave_reader.py index 63e6dda..268c75e 100644 --- a/wavinfo/wave_reader.py +++ b/wavinfo/wave_reader.py @@ -4,10 +4,7 @@ import os import sys from collections import namedtuple -if sys.version[0] == '3': - import pathlib -else: - import urlparse, urllib +import pathlib from .riff_parser import parse_chunk, ChunkDescriptor, ListChunkDescriptor from .wave_ixml_reader import WavIXMLFormat @@ -40,11 +37,8 @@ class WavInfoReader(): """ absolute_path = os.path.abspath(path) - if sys.version[0] == '3': - #: `file://` url for the file. - self.url = pathlib.Path(absolute_path).as_uri() - else: - self.url = urlparse.urljoin('file:', urllib.pathname2url(absolute_path)) + #: `file://` url for the file. + self.url = pathlib.Path(absolute_path).as_uri() with open(path, 'rb') as f: chunks = parse_chunk(f)