Commit graph

101 commits

Author SHA1 Message Date
Serene-Arc
a6e5201ff3 Apply formatting tools to all files
This is 'the big one', which touches every file so that it all conforms
to the given standard.
2023-10-22 09:53:18 +10:00
luzpaz
8419149c7a
Fix various typos 2023-08-09 21:26:15 -04:00
wisp3rwind
3965858ac1 replaygain: apply review feedback: fixup previous refactor, improve tests
by adding files which are not completely silent, thus hitting a different
code path in some calculations

The sample files were generated using
> sox -n whitenoise.flac synth 00:00:02 whitenoise
> ffmpeg -i whitenoise.flac whitenoise.opus
> ffmpeg -i whitenoise.flac whitenoise.mp3
2023-07-22 12:47:19 +02:00
wisp3rwind
1ef6b90786 add missing syspath conversions (1/3, tests)
these are mostly in the tests, which didn't cause issues since the
affected directories usually have nice ASCII paths. For consistency, it
is nicer to always invoke syspath. That also avoids deprecation warnings
for the bytestring interfaces on Python <= 3.5. The bytestring
interfaces were undeprecated with PEP 529 in Python 3.6, such that we
didn't observe any actual failures.
2023-06-24 14:52:46 +02:00
wisp3rwind
d24cf69269 remove old Python: remove util.text_string
This was a helper for situations when Python 2 and 3 APIs returned bytes
and unicode, respectively. In these situation, we should nowadays know
which of the two we receive, so there's no need to wrap & hide the
`bytes.decode()` anymore (when it is still required).

Detailed justification:

beets/ui/__init__.py:
- command line options are always parsed to str

beets/ui/commands.py:
- confuse's config.dump always returns str
- open(...) defaults to text mode, read()ing str

beetsplug/keyfinder.py:
- ...

beetsplug/web/__init__.py:
- internally, paths are always bytestrings
- additionally, I took the liberty to slighlty re-arrange the code: it
  makes sense to split off the basename first, since we're only
  interested in the unicode conversion of that part.

test/helper.py:
- capture_stdout() gives a StringIO, which yields str

test/test_ui.py:
- self.io, from _common.TestCase, ultimately contains a
  _common.DummyOut, which appears to be dealing with str (cf.
  DummyOut.get)
2022-12-24 13:09:26 +01:00
wisp3rwind
ad4c68112f test helper: add support for multi-disc album fixtures 2022-01-22 14:00:32 +01:00
wisp3rwind
807f124ef8 really remove all six imports
apparently, pyupgrade didn't know how to handle these...
2022-01-20 00:26:01 +01:00
Andrew Rogl
ee4268dabb Remove unused imports
Fix imports
Fix formatting
2021-08-26 20:59:48 +10:00
Andrew Rogl
1ec87a3bdd pyupgrade beetsplug and tests
All tests working
More tidy up to be done
2021-08-26 19:12:51 +10:00
Adrian Sampson
75c41c0546
Remove most six.PY2 checks 2021-08-19 16:45:11 -04:00
Carl Suster
10d41a1cbb tests: avoid non-test classes named Test*
When using pytest's test collector, any class with a name starting with
Test is collected. If it notices that the class has an `__init__` member
then it skips it with a warning since it's probably a false positive.
This isn't a big deal, but we can avoid warnings like this:

    test/test_ui_importer.py:33
      beets/test/test_ui_importer.py:33: PytestCollectionWarning: cannot collect test class 'TestTerminalImportSession' because it has a __init__ constructor
        class TestTerminalImportSession(TerminalImportSession):

simply by renaming TestX to XFixture.
2019-06-02 16:35:37 +10:00
Carl Suster
546bf3af7e mediafile: import from standalone module 2019-05-29 09:35:14 +10:00
Adrian Sampson
7edba6e9ea Fix test harness for named queries 2019-02-17 14:11:40 -05:00
David Logie
57b268923f Split release and release-group disambiguation into separate fields. 2018-09-05 12:45:19 +01:00
Jérémie Detrey
81e1fc1a7e test.helper: Allow extra track values in generate_album_info. 2018-05-08 17:02:38 +02:00
Meet Udeshi
70f0bc5b6c Implement album merging for duplicates
Fixes #112
2017-11-01 02:00:48 +05:30
zigarrre
b376139663 Refactored move functions for clarity according to #2682
The move functions in library.py and manipule_files in importer.py where
changed to use a single parameter for the file operation instead of
multiple boolean flags.

A typo in the documentation of the Album.move and Item.move functions
confusing True and False when describing the store parameter was fixed
as well.
2017-09-11 17:03:44 +02:00
wordofglass
7d4627bb8f Ensure mtime is non-zero for Items in test fixtures.
mtime == 0 is the "this Item contains newer metadata than the file's
tags" marker. Setting this to something else than 0 emulates the state
of Items freshly read from the database.

Breaks 4 of the edit plugin tests.
2017-08-22 23:24:33 +02: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
304df82361 rename/move ui._arg_encoding to util.arg_encoding
We use this for more than ui concerns, so it should be in util.

It is also no longer marked as a "private" method.
2016-08-04 17:16:11 -04:00
Johnny Robeson
f8049e67b4 add test helper method to convert cmd args on py2/3
This helper method converts args to bytes on python 2, and args to
strings on python 3
2016-07-25 02:59:41 -04:00
Johnny Robeson
9ab9166c8d add a lib keyword arg to the run_command test helper
Now a `Library` instance can be passed to run_command as a keyword
argument.
2016-07-25 00:43:33 -04:00
Johnny Robeson
7bb649c3b2 remove :memory: library fallback from test run_command 2016-07-25 00:16:09 -04:00
Johnny Robeson
18b57ea022 clear argv before running commands in the test suite
Fixes #2123
2016-07-14 03:33:29 -04:00
Johnny Robeson
fa3fe86ac1 remove bytes() wrap from test helper fixture
It was already bytes, so this was redundant. It also broke the tests
on windows with py3.
2016-07-05 02:06:13 -04:00
Johnny Robeson
9020dc1f45 use text_string() in a few places for io output 2016-07-02 00:03:46 -04:00
Johnny Robeson
aa0a0a0f22 use util.py3_path for confit and env paths in tests 2016-06-30 22:24:17 -04:00
Adrian Sampson
c532860613 Apply simple type consistency changes from #2096
These are the changes from that PR that just enforce the path type invariants
we already want---they're a good idea regardless of Python 3.
2016-06-30 14:22:16 -07:00
Johnny Robeson
ecfda77f5a bytestringify a few more paths in tests 2016-06-30 00:08:38 -04:00
Johnny Robeson
8c2809f75c only write StringIO encoding attr on py2 2016-06-24 05:53:56 -04:00
Johnny Robeson
e8afcbe7ec replace unicode with six.text_type 2016-06-24 05:53:49 -04:00
Johnny Robeson
5f4678e3e8 use StringIO from six 2016-06-23 04:40:18 -04:00
Johnny Robeson
0b17666b55 Revert "check for encoding attr before set in test_helper"
This doesn't actually help us, since the property is there, but not
writeable
This reverts commit 4c98edc588.
2016-06-22 00:51:10 -04:00
Johnny Robeson
4c98edc588 check for encoding attr before set in test_helper
This makes it work equivalently in py2 and py3
2016-06-21 23:44:24 -04:00
Johnny Robeson
60a961a751 remove an unnecessary .encode() in create_item_fixture 2016-06-17 01:20:42 -04:00
Johnny Robeson
1088df7242 bytestringify some more paths in test helper 2016-06-16 23:41:21 -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
f400a2431e fetchart: Fix path types on Windows 2016-06-08 10:20:25 -07:00
Adrian Sampson
2f9aa41614 Clean up SQLite connections in test harness
Windows complains that we can't remove the test database file if open
connections remain.
2016-06-05 11:56:09 -07:00
Adrian Sampson
1eb03a0de5 Query tests: use normalized paths
Match ordinary beets behavior by storing normalized paths in the
database. This matters on Windows, where normalization adds backslashes
and drive letters.
2016-05-31 13:12:32 -07: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
Peter Kessen
a5ce7a2814 Removed import of unicode_literals from testsuite 2016-02-20 14:46:37 +01:00
Jack Wilsdon
12cd5306b7 Update copyright dates to 2016 2015-12-30 15:42:06 +00: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
a0ff517d17 Guess output encoding from sys.stdout.encoding
Rather than using the locale settings. #1419
2015-04-13 11:11:16 -07:00
Bruno Cauet
adec09de96 Fix outdated docstring in test.TestHelper 2015-03-23 19:15:14 +01:00
Bruno Cauet
69786b8538 Fix test.helper.has_program(): encode command
subprocess.subprocess.check_call() should receive a byte string command
otherwise it fails with a UnicodeDecodeError on systems with non-ascii
elements in the system path.

Discovered while reviewing PR #1344.
2015-03-04 15:05:17 +01:00
Bruno Cauet
f1e13cf886 Offer verbose and very verbose modes
'verbose' is now an int and not a boolean. '-v' is level 1, '-vv' level
2. In the configuration it can be set with 'verbose: 1' or 'verbose: 2'.

Improve #1244: auditing current log levels of plugins remains.
2015-02-10 17:13:15 +01:00
Tom Jaspers
3ec44aab3e Update _types field instead of assigning it
Assigning it would override our pre-defined types
(such as `path` in Album._types)
2015-02-06 10:42:46 +01:00
Thomas Scholtes
482008bf1d Info plugin can filter properties in output
Resolves #1287
2015-02-01 21:51:26 +01:00