Skip to content

Commit c9f98fc

Browse files
committed
Use unittest.TestCase for tests that don't require the dir setup
1 parent e439c04 commit c9f98fc

13 files changed

+28
-29
lines changed

test/plugins/test_art.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import os
2020
import shutil
21+
import unittest
2122
from typing import TYPE_CHECKING
2223
from unittest.mock import patch
2324

@@ -1012,7 +1013,7 @@ def test_deinterlace_and_resize(self):
10121013
self._assert_image_operated(self.IMG_348x348, self.RESIZE_OP, True)
10131014

10141015

1015-
class DeprecatedConfigTest(BeetsTestCase):
1016+
class DeprecatedConfigTest(unittest.TestCase):
10161017
"""While refactoring the plugin, the remote_priority option was deprecated,
10171018
and a new codepath should translate its effect. Check that it actually does
10181019
so.
@@ -1030,7 +1031,7 @@ def test_moves_filesystem_to_end(self):
10301031
assert isinstance(self.plugin.sources[-1], fetchart.FileSystem)
10311032

10321033

1033-
class EnforceRatioConfigTest(BeetsTestCase):
1034+
class EnforceRatioConfigTest(unittest.TestCase):
10341035
"""Throw some data at the regexes."""
10351036

10361037
def _load_with_config(self, values, should_raise):

test/plugins/test_beatport.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Tests for the 'beatport' plugin."""
1616

17+
import unittest
1718
from datetime import timedelta
1819

1920
from beets.test import _common
@@ -585,7 +586,7 @@ def test_genre_applied(self):
585586
assert track.genre == test_track.genre
586587

587588

588-
class BeatportResponseEmptyTest(BeetsTestCase):
589+
class BeatportResponseEmptyTest(unittest.TestCase):
589590
def _make_tracks_response(self):
590591
results = [
591592
{

test/plugins/test_lastgenre.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414

1515
"""Tests for the 'lastgenre' plugin."""
1616

17+
import unittest
1718
from unittest.mock import Mock
1819

1920
import pytest
2021

2122
from beets import config
2223
from beets.test import _common
23-
from beets.test.helper import BeetsTestCase
2424
from beetsplug import lastgenre
2525

2626

27-
class LastGenrePluginTest(BeetsTestCase):
27+
class LastGenrePluginTest(unittest.TestCase):
2828
def setUp(self):
2929
super().setUp()
3030
self.plugin = lastgenre.LastGenrePlugin()

test/plugins/test_musicbrainz.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Tests for MusicBrainz API wrapper."""
1616

17+
import unittest
1718
from unittest import mock
1819

1920
import pytest
@@ -665,7 +666,7 @@ def test_track_disambiguation(self):
665666
assert t[1].trackdisambig == "SECOND TRACK"
666667

667668

668-
class ArtistFlatteningTest(BeetsTestCase):
669+
class ArtistFlatteningTest(unittest.TestCase):
669670
def _credit_dict(self, suffix=""):
670671
return {
671672
"artist": {

test/plugins/test_subsonicupdate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Tests for the 'subsonic' plugin."""
22

3+
import unittest
34
from urllib.parse import parse_qs, urlparse
45

56
import responses
67

78
from beets import config
8-
from beets.test.helper import BeetsTestCase
99
from beetsplug import subsonicupdate
1010

1111

@@ -24,7 +24,7 @@ def _params(url):
2424
return parse_qs(urlparse(url).query)
2525

2626

27-
class SubsonicPluginTest(BeetsTestCase):
27+
class SubsonicPluginTest(unittest.TestCase):
2828
"""Test class for subsonicupdate."""
2929

3030
@responses.activate

test/plugins/test_the.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Tests for the 'the' plugin"""
22

3+
import unittest
4+
35
from beets import config
4-
from beets.test.helper import BeetsTestCase
56
from beetsplug.the import FORMAT, PATTERN_A, PATTERN_THE, ThePlugin
67

78

8-
class ThePluginTest(BeetsTestCase):
9+
class ThePluginTest(unittest.TestCase):
910
def test_unthe_with_default_patterns(self):
1011
assert ThePlugin().unthe("", PATTERN_THE) == ""
1112
assert (

test/test_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def test_hardlink_changes_path(self):
200200
assert self.i.path == util.normpath(self.dest)
201201

202202

203-
class HelperTest(BeetsTestCase):
203+
class HelperTest(unittest.TestCase):
204204
def test_ancestry_works_on_file(self):
205205
p = "/a/b/c"
206206
a = ["/", "/a", "/a/b"]

test/test_importer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ def test_choose_second_candidate(self):
924924
assert self.lib.albums().get().album == "Applied Album MM"
925925

926926

927-
class InferAlbumDataTest(BeetsTestCase):
927+
class InferAlbumDataTest(unittest.TestCase):
928928
def setUp(self):
929929
super().setUp()
930930

@@ -1220,7 +1220,7 @@ def add_item_fixture(self, **kwargs):
12201220
return item
12211221

12221222

1223-
class TagLogTest(BeetsTestCase):
1223+
class TagLogTest(unittest.TestCase):
12241224
def test_tag_log_line(self):
12251225
sio = StringIO()
12261226
handler = logging.StreamHandler(sio)

test/test_logging.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
import logging as log
44
import sys
55
import threading
6+
import unittest
67
from io import StringIO
78

89
import beets.logging as blog
910
import beetsplug
1011
from beets import plugins, ui
1112
from beets.test import _common, helper
12-
from beets.test.helper import (
13-
AsIsImporterMixin,
14-
BeetsTestCase,
15-
ImportTestCase,
16-
PluginMixin,
17-
)
13+
from beets.test.helper import AsIsImporterMixin, ImportTestCase, PluginMixin
1814

1915

20-
class LoggingTest(BeetsTestCase):
16+
class LoggingTest(unittest.TestCase):
2117
def test_logging_management(self):
2218
l1 = log.getLogger("foo123")
2319
l2 = blog.getLogger("foo123")

test/test_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def test_invalid_query(self):
373373
dbcore.query.RegexpQuery("year", "199(")
374374

375375

376-
class MatchTest(BeetsTestCase):
376+
class MatchTest(unittest.TestCase):
377377
def setUp(self):
378378
super().setUp()
379379
self.item = _common.item()
@@ -811,7 +811,7 @@ def test_match_slow_after_set_none(self):
811811
self.assertInResult(item, matched)
812812

813813

814-
class NotQueryMatchTest(BeetsTestCase):
814+
class NotQueryMatchTest(unittest.TestCase):
815815
"""Test `query.NotQuery` matching against a single item, using the same
816816
cases and assertions as on `MatchTest`, plus assertion on the negated
817817
queries (ie. assert q -> assert not NotQuery(q)).

test/test_sort.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def test_config_opposite_sort_album(self):
378378
assert results[0].albumartist > results[1].albumartist
379379

380380

381-
class CaseSensitivityTest(DummyDataTestCase, BeetsTestCase):
381+
class CaseSensitivityTest(DummyDataTestCase):
382382
"""If case_insensitive is false, lower-case values should be placed
383383
after all upper-case values. E.g., `Foo Qux bar`
384384
"""

test/test_ui.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ def test_item_data_change_wrap_newline(self):
13371337

13381338

13391339
@patch("beets.library.Item.try_filesize", Mock(return_value=987))
1340-
class SummarizeItemsTest(BeetsTestCase):
1340+
class SummarizeItemsTest(unittest.TestCase):
13411341
def setUp(self):
13421342
super().setUp()
13431343
item = library.Item()
@@ -1374,7 +1374,7 @@ def test_summarize_items(self):
13741374
assert summary == "3 items, G 2, F 1, 4kbps, 32:42, 2.9 KiB"
13751375

13761376

1377-
class PathFormatTest(BeetsTestCase):
1377+
class PathFormatTest(unittest.TestCase):
13781378
def test_custom_paths_prepend(self):
13791379
default_formats = ui.get_path_formats()
13801380

@@ -1521,7 +1521,7 @@ def test_version(self):
15211521
# assert 'plugins: ' in output
15221522

15231523

1524-
class CommonOptionsParserTest(BeetsTestCase):
1524+
class CommonOptionsParserTest(unittest.TestCase):
15251525
def test_album_option(self):
15261526
parser = ui.CommonOptionsParser()
15271527
assert not parser._album_flags
@@ -1614,7 +1614,7 @@ def test_add_all_common_options(self):
16141614
)
16151615

16161616

1617-
class EncodingTest(BeetsTestCase):
1617+
class EncodingTest(unittest.TestCase):
16181618
"""Tests for the `terminal_encoding` config option and our
16191619
`_in_encoding` and `_out_encoding` utility functions.
16201620
"""

test/test_util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
from beets import util
2727
from beets.test import _common
28-
from beets.test.helper import BeetsTestCase
2928

3029

3130
class UtilTest(unittest.TestCase):
@@ -132,7 +131,7 @@ def test_case_sensitive_detects_insensitive(self):
132131
pass
133132

134133

135-
class PathConversionTest(BeetsTestCase):
134+
class PathConversionTest(unittest.TestCase):
136135
def test_syspath_windows_format(self):
137136
with _common.platform_windows():
138137
path = os.path.join("a", "b", "c")

0 commit comments

Comments
 (0)