mirror of
https://github.com/beetbox/beets.git
synced 2026-02-21 14:56:02 +01:00
Fix IMBackend#compare on ImageMagick 7.1.1-44 (#5650)
This commit is contained in:
commit
1f93867401
3 changed files with 15 additions and 9 deletions
|
|
@ -314,6 +314,11 @@ class IMBackend(LocalBackend):
|
|||
else:
|
||||
out_str = stdout
|
||||
|
||||
# ImageMagick 7.1.1-44 outputs in a different format.
|
||||
if b"(" in out_str and out_str.endswith(b")"):
|
||||
# Extract diff from "... (diff)".
|
||||
out_str = out_str[out_str.index(b"(") + 1 : -1]
|
||||
|
||||
try:
|
||||
phash_diff = float(out_str)
|
||||
except ValueError:
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ Bug fixes:
|
|||
* :doc:`plugins/lyrics`: Fix plugin crash when ``genius`` backend returns empty
|
||||
lyrics.
|
||||
:bug:`5583`
|
||||
* ImageMagick 7.1.1-44 is now supported.
|
||||
|
||||
For packagers:
|
||||
|
||||
|
|
|
|||
|
|
@ -285,8 +285,8 @@ class ArtSimilarityTest(unittest.TestCase):
|
|||
mock_extract,
|
||||
mock_subprocess,
|
||||
compare_status=0,
|
||||
compare_stdout="",
|
||||
compare_stderr="",
|
||||
compare_stdout=b"",
|
||||
compare_stderr=b"",
|
||||
convert_status=0,
|
||||
):
|
||||
mock_extract.return_value = b"extracted_path"
|
||||
|
|
@ -298,33 +298,33 @@ class ArtSimilarityTest(unittest.TestCase):
|
|||
]
|
||||
|
||||
def test_compare_success_similar(self, mock_extract, mock_subprocess):
|
||||
self._mock_popens(mock_extract, mock_subprocess, 0, "10", "err")
|
||||
self._mock_popens(mock_extract, mock_subprocess, 0, b"10", b"err")
|
||||
assert self._similarity(20)
|
||||
|
||||
def test_compare_success_different(self, mock_extract, mock_subprocess):
|
||||
self._mock_popens(mock_extract, mock_subprocess, 0, "10", "err")
|
||||
self._mock_popens(mock_extract, mock_subprocess, 0, b"10", b"err")
|
||||
assert not self._similarity(5)
|
||||
|
||||
def test_compare_status1_similar(self, mock_extract, mock_subprocess):
|
||||
self._mock_popens(mock_extract, mock_subprocess, 1, "out", "10")
|
||||
self._mock_popens(mock_extract, mock_subprocess, 1, b"out", b"10")
|
||||
assert self._similarity(20)
|
||||
|
||||
def test_compare_status1_different(self, mock_extract, mock_subprocess):
|
||||
self._mock_popens(mock_extract, mock_subprocess, 1, "out", "10")
|
||||
self._mock_popens(mock_extract, mock_subprocess, 1, b"out", b"10")
|
||||
assert not self._similarity(5)
|
||||
|
||||
def test_compare_failed(self, mock_extract, mock_subprocess):
|
||||
self._mock_popens(mock_extract, mock_subprocess, 2, "out", "10")
|
||||
self._mock_popens(mock_extract, mock_subprocess, 2, b"out", b"10")
|
||||
assert self._similarity(20) is None
|
||||
|
||||
def test_compare_parsing_error(self, mock_extract, mock_subprocess):
|
||||
self._mock_popens(mock_extract, mock_subprocess, 0, "foo", "bar")
|
||||
self._mock_popens(mock_extract, mock_subprocess, 0, b"foo", b"bar")
|
||||
assert self._similarity(20) is None
|
||||
|
||||
def test_compare_parsing_error_and_failure(
|
||||
self, mock_extract, mock_subprocess
|
||||
):
|
||||
self._mock_popens(mock_extract, mock_subprocess, 1, "foo", "bar")
|
||||
self._mock_popens(mock_extract, mock_subprocess, 1, b"foo", b"bar")
|
||||
assert self._similarity(20) is None
|
||||
|
||||
def test_convert_failure(self, mock_extract, mock_subprocess):
|
||||
|
|
|
|||
Loading…
Reference in a new issue