Commit graph

44 commits

Author SHA1 Message Date
Sebastian Reuße
c40ea4f22a mediafile._safe_cast: be safer when converting to int
The regex «[\+-]?[0-9]*» possibly matches a single minus/plus, which would then
be passed on to int(), raising a ValueError from within _safe_cast. The test
suite covered this for float, but not for int.

We now make sure we actually have a number after the sign by using a Kleene
plus.
2017-11-19 09:21:07 +01:00
Adrian Sampson
d8c0a42e6c Avoid TestHelper dependency in MediaFile tests
Part of #1966. This also introduces a nicer, more lightweight way to create and
destroy temporary directories, decoupling that functionality from the
giant morass that is TestHelper.
2016-11-26 18:55:58 -05:00
Adrian Sampson
a88682e7bb Undo from _common import unittest indirection
This was a vestige from when we used to need the unittest2 library for pre-2.7
compatibility. Now that we require Python 2.7, we aren't using that library
and this indirection wasn't doing any good.
2016-11-26 18:46:44 -05:00
Adrian Sampson
24940c0de7 In MediaFile tests, use simpler import path
This will make it easier to copy these tests into their own repository.
2016-11-26 18:27:20 -05:00
Adrian Sampson
788654736d Obviate the need for a beets utility in MF tests
Even more on #1966.
2016-11-26 18:26:18 -05:00
Christoph Reiter
31f91129f3 Use mutagen id3 encoding constants 2016-11-19 10:36:31 +01:00
Christoph Reiter
31898111ed mediafile: prefer latin-1 encoding for ID3 APIC descriptions. Fixes #899
iTunes has problems with everything but latin-1
Try to use latin-1 if possible and fall back to utf-16.
2016-11-18 01:09:53 +01:00
nathdwek@laptop
e782885e50 embedart: Adapt tests for #2254 2016-11-08 18:48:44 +01:00
nathdwek@laptop
a0877dc092 images: Make sure all jpegs work everywhere
Apply #1545 to a public function used everywhere
2016-11-08 18:48:44 +01:00
Johnny Robeson
7a2bdf502f s/utf8/utf-8/ in all encoding/decoding contexts
This matches up with the python documentation.
2016-09-06 23:10:24 -04:00
Johnny Robeson
d41949d326 close files we open, but forgot to close
This fixes all the obvious `ResourceWarning`s seen in the tests
2016-08-09 01:15:28 -04:00
Johnny Robeson
cae6e128e4 use same symlink test in mediafile_edge as elsewhere 2016-07-05 01:29:38 -04:00
Christoph Reiter
629241efd3 mediafile: Cleanup mutagen error handling
Instead of the individial mutagen format exceptions use the
mutagen.MutagenError exception introduced in 1.25.

Since 1.33 mutagen will only raise MutagenError for load/save/delete
and no longer raise IOError. Translate both errors to UnreadableFileError
to support older and newer mutagen versions. Unify error handling
in __init__(), save() and delete().

Since it's no longer possible to get an IOError from MediaFile, adjust
all callers and tests accordingly.

This was tested with mutagen 1.27 and current mutagen master.
2016-06-28 16:43:34 +02:00
Johnny Robeson
e8afcbe7ec replace unicode with six.text_type 2016-06-24 05:53:49 -04:00
Johnny Robeson
ffa46a185c bytestring normalization
Make sure many/most strings that touch the filesystem are
converted explicitly to bytestrings rather than implictly.
2016-06-13 05:39:09 -04:00
Adrian Sampson
71b9fd785c Revert "Do __name__ comparison with bytes and not unicode"
This reverts commit 9c41c39913.
That commit used byte strings for the `if __name__ == '__main__'` pattern,
which was necessary when we were doing unicode_literals. But it is wrong on
Python 3, and now that we're liberated from unicode_literals, we need to go
back to native strings for this comparison.
2016-05-29 19:19:59 -07:00
Johnny Robeson
5963595f32 Add safe_cast tests for . and 1.0.0 2016-05-26 00:57:16 -04:00
Adrian Sampson
eac7d64545 Merge branch 'master' into no_unicode_literals 2016-02-28 15:21:43 -08:00
Adrian Sampson
e54c7eec3d Standardize __future__ imports without parentheses
Since the list is short enough now, we don't need parentheses for the line
wrap. This is a little less ugly.
2016-02-28 15:03:51 -08:00
Adrian Sampson
48659c5df4 Fix #1896 (bungled fix to #1895) 2016-02-28 13:37:01 -08:00
Peter Kessen
fe1e8b5687 Removed unicode_literals from test_mediafile_edge 2016-02-24 07:32:10 +01:00
Jack Wilsdon
12cd5306b7 Update copyright dates to 2016 2015-12-30 15:42:06 +00:00
Adrian Sampson
659fab2ca9 Fix #879 (again): update ID3 string encodings 2015-12-10 14:30:25 -08:00
Peter Kessen
3eb8008b11 added encoding as comment in files
added line like
# -*- coding: utf-8 -*-
to all files with correct license in header
2015-11-19 18:41:01 +01:00
Adrian Sampson
9c968456c1 Fix #1666: malformed binary data in SoundCheck 2015-11-13 12:21:36 -08:00
nath@home
fc507faee2 added comment to the test 2015-07-21 19:53:20 +02:00
nath@home
b444ec496c
simple testing for wider_jpeg_detection now done in test_mediafile_edge.py 2015-07-21 18:40:49 +02:00
Bruno Cauet
02d8e88ef1 Replace all mentions of 'str' with 'bytes' 2015-01-20 12:48:15 +01:00
Bruno Cauet
9c41c39913 Do __name__ comparison with bytes and not unicode 2015-01-20 12:03:57 +01:00
Bruno Cauet
2dab8e5fd6 Import unicode_literals in beets package 2015-01-19 21:41:33 +01:00
Bruno Cauet
90b388b775 Use __future__ imports but unicode_literals everywhere
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.

Goal is smoothing the transition to python 3.
2015-01-19 12:25:16 +01:00
Bruno Cauet
2902cda036 tests: use absolute imports everywhere 2015-01-19 12:25:15 +01:00
Frederik “Freso” S. Olesen
4b1f0cbf48 Happy 2015. ;)
See 7a410f636b

Command used:

    git grep -l 'Copyright 201'|xargs sed -i -E 's/Copyright 201./Copyright 2015/'`
2015-01-08 21:37:09 +01:00
Adrian Sampson
4ecaa4239f Fix unittest.skip decorator use
This fixes the py26 build.
2014-08-18 17:11:08 -07:00
Adrian Sampson
bf553eae34 MediaFile: detect missing numbers (fix #901) 2014-08-18 10:17:01 -07:00
Adrian Sampson
09b0e1c75d Add failing test for #899 2014-08-15 12:38:41 -07:00
Adrian Sampson
7de6259c1d MediaFile: make id3v23 a constructor parameter
For #899, we need to change MediaFile's behavior (pre-write) based on whether
we're doing ID3v2.3 or not. So we need a field on the object, not a parameter
to `save()`.
2014-08-15 12:09:18 -07:00
Adrian Sampson
943cbe0838 MediaFile: allow setting date fields to None 2014-05-18 15:14:36 -07:00
Adrian Sampson
309c5c1a58 fix #705: unicode in SoundCheck fields 2014-04-17 18:10:16 -07:00
Adrian Sampson
77eddaa2d1 properly sandbox all tests
All filesystem writes are now to temporary directories. (Long ago, the policy
was to put temporary stuff in _RSRC, but that was a pretty bad idea.)
2014-04-12 19:29:29 -07:00
Thomas Scholtes
a6839603cd Return None for missing tags.
Instead of returning a special "None value" if a tag does not exist, we return
none directly.
2014-04-09 23:28:11 +02:00
Thomas Scholtes
0832b9b346 Move mediafile cast logic to storage style
StorageStyle.get should return a python builtin type.
This amends 5716cd1024
2014-03-07 16:32:21 +01:00
Johannes
5716cd1024 Fix _safe_cast of ASFUnicodeAttribute
Fixes #578
2014-03-06 00:21:33 +00:00
Thomas Scholtes
9f59592a88 Basic test cases should come first 2014-02-13 14:24:49 +01:00