import distro import pytest from libretime_analyzer.ffmpeg import compute_replaygain, probe_replaygain from .fixtures import FILES @pytest.mark.skip(reason="fixtures files are missing replaygain metadata") @pytest.mark.parametrize( "filepath,replaygain", map(lambda i: pytest.param(i.path, i.replaygain, id=i.path.name), FILES), ) def test_probe_replaygain(filepath, replaygain): assert probe_replaygain(filepath) == pytest.approx(replaygain, abs=0.05) @pytest.mark.parametrize( "filepath,replaygain", map(lambda i: pytest.param(i.path, i.replaygain, id=i.path.name), FILES), ) def test_compute_replaygain(filepath, replaygain): tolerance = 0.8 # On bionic, replaygain is a bit higher for loud mp3 files. # This huge tolerance makes the test pass, with values devianting from ~-17 to ~-13 if distro.codename() == "bionic" and str(filepath).endswith("+12.mp3"): tolerance = 5 assert compute_replaygain(filepath) == pytest.approx(replaygain, abs=tolerance)