eyeD3
eyeD3 copied to clipboard
Test regression with ruamel.yaml 0.17.26 (possibly older)
After upgrading ruamel.yaml
to 0.17.26 (possibly older versions), the formatting changes and causes the test suite to fail:
$ python -m pytest tests/test_jsonyaml_plugin.py::testYamlPlugin
========================================================= test session starts =========================================================
platform linux -- Python 3.11.3, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /tmp/eyeD3
plugins: Faker-18.9.0, cov-2.12.1
collected 1 item
tests/test_jsonyaml_plugin.py F [100%]
============================================================== FAILURES ===============================================================
___________________________________________________________ testYamlPlugin ____________________________________________________________
audiofile = <eyed3.mp3.Mp3AudioFile object at 0x7f7b95551f50>
def testYamlPlugin(audiofile):
_initTag(audiofile)
omap, omap_list = "", " "
if sys.version_info[:2] <= (3, 7):
omap = " !!omap"
omap_list = "- "
> _assertFormat("yaml", audiofile, f"""
---
_eyeD3: %(version)s
album: Suffer
artist: Bad Religion
best_release_date: '1988'
info:
size_bytes: %(size_bytes)d
time_secs: 10.68
path: %(path)s
recording_date: '1987'
release_date: '1988'
title: Suffer
track_num:{omap}
{omap_list}count: 9
{omap_list}total: 15
""")
tests/test_jsonyaml_plugin.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
plugin = 'yaml', audio_file = <eyed3.mp3.Mp3AudioFile object at 0x7f7b95551f50>
format = "\n---\n_eyeD3: %(version)s\nalbum: Suffer\nartist: Bad Religion\nbest_release_date: '1988'\ninfo:\n size_bytes: %(si...68\npath: %(path)s\nrecording_date: '1987'\nrelease_date: '1988'\ntitle: Suffer\ntrack_num:\n count: 9\n total: 15\n"
def _assertFormat(plugin: str, audio_file, format: str):
output = _runPlugin(audio_file, plugin)
print(output)
size_bytes = os.stat(audio_file.path)[stat.ST_SIZE]
> assert output.strip() == format.strip() % dict(path=audio_file.path, version=version,
size_bytes=size_bytes)
E AssertionError: assert '---\n_eyeD3:...\n total: 15' == '---\n_eyeD3:...\n total: 15'
E Skipping 121 identical leading characters in diff, use -v to show
E .68
E + path:
E - path: /tmp/pytest-of-mgorny/pytest-5/testYamlPlugin0/c0206a04-1567-450c-bad1-65fac0776c7b.mp3
E ? ^^^^^
E + /tmp/pytest-of-mgorny/pytest-5/testYamlPlugin0/c0206a04-1567-450c-bad1-65fac0776c7b.mp3
E ? ^...
E
E ...Full output truncated (7 lines hidden), use '-vv' to show
tests/test_jsonyaml_plugin.py:33: AssertionError
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
---
_eyeD3: 0.9.7
album: Suffer
artist: Bad Religion
best_release_date: '1988'
info:
size_bytes: 170886
time_secs: 10.68
path:
/tmp/pytest-of-mgorny/pytest-5/testYamlPlugin0/c0206a04-1567-450c-bad1-65fac0776c7b.mp3
recording_date: '1987'
release_date: '1988'
title: Suffer
track_num:
count: 9
total: 15
---
_eyeD3: 0.9.7
album: Suffer
artist: Bad Religion
best_release_date: '1988'
info:
size_bytes: 170886
time_secs: 10.68
path:
/tmp/pytest-of-mgorny/pytest-5/testYamlPlugin0/c0206a04-1567-450c-bad1-65fac0776c7b.mp3
recording_date: '1987'
release_date: '1988'
title: Suffer
track_num:
count: 9
total: 15
========================================================== warnings summary ===========================================================
tests/test_jsonyaml_plugin.py::testYamlPlugin
/tmp/eyeD3/eyed3/plugins/jsontag.py:42: DeprecationWarning: Use Tag.getBestDate() instead
member = getattr(tag, name)
tests/test_jsonyaml_plugin.py::testYamlPlugin
/tmp/eyeD3/eyed3/plugins/yamltag.py:29: PendingDeprecationWarning:
safe_dump will be removed, use
yaml=YAML(typ='safe', pure=True)
yaml.dump(...)
instead
print(yaml.safe_dump(audioFileToJson(self.audio_file),
tests/test_jsonyaml_plugin.py::testYamlPlugin
/tmp/eyeD3/.tox/py311/lib/python3.11/site-packages/ruamel/yaml/main.py:1390: PendingDeprecationWarning:
dump_all will be removed, use
yaml=YAML(typ='unsafe', pure=True)
yaml.dump_all(...)
instead
return dump_all([data], stream, Dumper=SafeDumper, **kwds)
-- Docs: https://docs.pytest.org/en/stable/warnings.html
======================================================= short test summary info =======================================================
FAILED tests/test_jsonyaml_plugin.py::testYamlPlugin - AssertionError: assert '---\n_eyeD3:...\n total: 15' == '---\n_eyeD3:...\n ...
==================================================== 1 failed, 3 warnings in 0.30s ====================================================
And the safe_dump warning is now an error:
=============================================================== FAILURES ================================================================
____________________________________________________________ testYamlPlugin _____________________________________________________________
audiofile = <eyed3.mp3.Mp3AudioFile object at 0x7ed97c4fa0f0>
def testYamlPlugin(audiofile):
_initTag(audiofile)
omap, omap_list = "", " "
if sys.version_info[:2] <= (3, 7):
omap = " !!omap"
omap_list = "- "
> _assertFormat("yaml", audiofile, f"""
---
_eyeD3: %(version)s
album: Suffer
artist: Bad Religion
best_release_date: '1988'
info:
size_bytes: %(size_bytes)d
time_secs: 10.68
path: %(path)s
recording_date: '1987'
release_date: '1988'
title: Suffer
track_num:{omap}
{omap_list}count: 9 10:46:56 [40/856]
{omap_list}total: 15
""")
tests/test_jsonyaml_plugin.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_jsonyaml_plugin.py:30: in _assertFormat
output = _runPlugin(audio_file, plugin)
tests/test_jsonyaml_plugin.py:22: in _runPlugin
assert main.main(args, config) == 0
eyed3/main.py:41: in main
eyed3.utils.walk(args.plugin, p, excludes=args.excludes, fs_encoding=args.fs_encoding,
eyed3/utils/__init__.py:71: in walk
handler.handleFile(os.path.abspath(path))
eyed3/plugins/yamltag.py:29: in handleFile
print(yaml.safe_dump(audioFileToJson(self.audio_file),
/usr/lib/python3.12/site-packages/ruamel/yaml/main.py:1260: in safe_dump
error_deprecation('safe_dump', 'dump', arg="typ='safe', pure=True")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
fun = 'safe_dump', method = 'dump', arg = "typ='safe', pure=True", comment = 'instead of'
def error_deprecation(fun: Any, method: Any, arg: str = '', comment: str = 'instead of') -> None: # NOQA
import inspect
s = f'\n"{fun}()" has been removed, use\n\n yaml = YAML({arg})\n yaml.{method}(...)\n\n{comment}' # NOQA
try:
info = inspect.getframeinfo(inspect.stack()[2][0])
context = '' if info.code_context is None else "".join(info.code_context)
s += f' file "{info.filename}", line {info.lineno}\n\n{context}'
except Exception as e:
_ = e
s += '\n'
if sys.version_info < (3, 10):
raise AttributeError(s)
else:
> raise AttributeError(s, name=None)
E AttributeError:
E "safe_dump()" has been removed, use
E
E yaml = YAML(typ='safe', pure=True)
E yaml.dump(...)
E
E instead of file "/home/mark/.cache/paru/clone/python-eyed3/src/eyeD3-0.9.7/eyed3/plugins/yamltag.py", line 29
E
E print(yaml.safe_dump(audioFileToJson(self.audio_file),
/usr/lib/python3.12/site-packages/ruamel/yaml/main.py:1039: AttributeError