mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-10-01 17:27:42 +00:00
Ruff
This commit is contained in:
+5
-3
@@ -42,12 +42,14 @@ class TestADMWave(TestCase):
|
||||
adm = info.adm
|
||||
assert adm is not None
|
||||
t1 = adm.track_info(0)
|
||||
self.assertTrue("channel_format_name" in t1.keys())
|
||||
assert t1 is not None
|
||||
self.assertTrue("channel_format_name" in t1)
|
||||
self.assertEqual("RoomCentricLeft", t1["channel_format_name"])
|
||||
|
||||
self.assertTrue("pack_format_name" in t1.keys())
|
||||
self.assertTrue("pack_format_name" in t1)
|
||||
self.assertEqual("AtmosCustomPackFormat1", t1["pack_format_name"])
|
||||
|
||||
t10 = adm.track_info(10)
|
||||
self.assertTrue("content_name" in t10.keys())
|
||||
assert t10 is not None
|
||||
self.assertTrue("content_name" in t10)
|
||||
self.assertEqual("Dialog", t10["content_name"])
|
||||
|
||||
+3
-12
@@ -9,24 +9,15 @@ from wavinfo.__main__ import main
|
||||
class MainTest(unittest.TestCase):
|
||||
def test_empty_argv(self):
|
||||
with patch.object(sys, "argv", []):
|
||||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
self.fail(f"main() throwing an exception: {e}")
|
||||
main()
|
||||
|
||||
def test_a_file(self):
|
||||
for path in glob.glob("tests/test_files/**/*.wav"):
|
||||
with patch.object(sys, "argv", ["TEST", path]):
|
||||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
self.fail(f"main() throwing an exception: {e}")
|
||||
main()
|
||||
|
||||
def test_ixml(self):
|
||||
with patch.object(
|
||||
sys, "argv", ["TEST", "--ixml", "tests/test_files/sounddevices/A101_1.WAV"]
|
||||
):
|
||||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
self.fail(f"main() throwing an exception: {e}")
|
||||
main()
|
||||
|
||||
+7
-9
@@ -11,12 +11,10 @@ class TestWalk(unittest.TestCase):
|
||||
|
||||
tested_data, tested_format = False, False
|
||||
for scope, key, value in info.walk():
|
||||
if scope == "fmt":
|
||||
if key == "channel_count":
|
||||
if scope == "fmt" and key == "channel_count":
|
||||
tested_format = True
|
||||
self.assertEqual(value, 2)
|
||||
if scope == "data":
|
||||
if key == "frame_count":
|
||||
if scope == "data" and key == "frame_count":
|
||||
tested_data = True
|
||||
self.assertEqual(value, 144140)
|
||||
|
||||
@@ -26,11 +24,11 @@ class TestWalk(unittest.TestCase):
|
||||
for file in glob.glob("tests/test_files/**/*.wav"):
|
||||
info = wavinfo.WavInfoReader(file)
|
||||
|
||||
try:
|
||||
for _, _, _ in info.walk():
|
||||
pass
|
||||
except Exception as e:
|
||||
self.fail(f"Failed to walk metadata in file {file}: {e}")
|
||||
# try:
|
||||
for _, _, _ in info.walk():
|
||||
pass
|
||||
# except Exception as e:
|
||||
# self.fail(f"Failed to walk metadata in file {file}: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -14,7 +14,7 @@ class TestWaveInfo(TestCase):
|
||||
info = wavinfo.WavInfoReader(wav_file)
|
||||
self.assertEqual(
|
||||
info.__repr__(),
|
||||
"WavInfoReader({}, latin_1, ascii)".format(os.path.abspath(wav_file)),
|
||||
f"WavInfoReader({os.path.abspath(wav_file)}, latin_1, ascii)",
|
||||
)
|
||||
self.assertIsNotNone(info)
|
||||
|
||||
|
||||
+5
-17
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
from subprocess import PIPE
|
||||
|
||||
FFPROBE = "ffprobe"
|
||||
@@ -9,23 +8,12 @@ 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
|
||||
process = subprocess.run(arguments, stdin=None, stdout=PIPE, stderr=PIPE, check=True)
|
||||
if process.returncode == 0:
|
||||
output_str = process.stdout.decode("utf-8")
|
||||
return json.loads(output_str)
|
||||
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
|
||||
return None
|
||||
|
||||
|
||||
def all_files():
|
||||
|
||||
Reference in New Issue
Block a user