Remove def suite TestLoader definitions

This commit is contained in:
Šarūnas Nejus 2024-07-07 17:48:08 +01:00
parent 432da560e4
commit fcff5d72af
No known key found for this signature in database
GPG key ID: DD28F6704DBE3435
71 changed files with 3 additions and 623 deletions

View file

@ -99,11 +99,3 @@ class MapDataToSchemeTest(unittest.TestCase):
("timbre", "bright"), ("timbre", "bright"),
} }
self.assertEqual(mapping, expected) self.assertEqual(mapping, expected)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -15,7 +15,6 @@
"""Test the advancedrewrite plugin for various configurations. """Test the advancedrewrite plugin for various configurations.
""" """
import unittest
from beets.test.helper import BeetsTestCase from beets.test.helper import BeetsTestCase
from beets.ui import UserError from beets.ui import UserError
@ -154,11 +153,3 @@ class AdvancedRewritePluginTest(BeetsTestCase):
album="C", album="C",
) )
self.assertEqual(item.artist, "D") self.assertEqual(item.artist, "D")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -24,6 +24,7 @@ from beetsplug.albumtypes import AlbumTypesPlugin
class AlbumTypesPluginTest(PluginTestCase): class AlbumTypesPluginTest(PluginTestCase):
"""Tests for albumtypes plugin.""" """Tests for albumtypes plugin."""
plugin = "albumtypes" plugin = "albumtypes"
def test_renames_types(self): def test_renames_types(self):

View file

@ -17,7 +17,6 @@
import os import os
import shutil import shutil
import unittest
from unittest.mock import patch from unittest.mock import patch
import confuse import confuse
@ -1016,11 +1015,3 @@ class EnforceRatioConfigTest(BeetsTestCase):
def test_percent(self): def test_percent(self):
self._load_with_config("0% 0.00% 5.1% 5% 100%".split(), False) self._load_with_config("0% 0.00% 5.1% 5% 100%".split(), False)
self._load_with_config("00% 1.234% foo5% 100.1%".split(), True) self._load_with_config("00% 1.234% foo5% 100.1%".split(), True)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -3,7 +3,6 @@
"""Tests for the 'bareasc' plugin.""" """Tests for the 'bareasc' plugin."""
import unittest
from beets import logging from beets import logging
from beets.test.helper import PluginTestCase, capture_stdout from beets.test.helper import PluginTestCase, capture_stdout
@ -11,6 +10,7 @@ from beets.test.helper import PluginTestCase, capture_stdout
class BareascPluginTest(PluginTestCase): class BareascPluginTest(PluginTestCase):
"""Test bare ASCII query matching.""" """Test bare ASCII query matching."""
plugin = "bareasc" plugin = "bareasc"
def setUp(self): def setUp(self):
@ -81,12 +81,3 @@ class BareascPluginTest(PluginTestCase):
) )
self.assertEqual("Antonin Dvorak:: with accents\n", output.getvalue()) self.assertEqual("Antonin Dvorak:: with accents\n", output.getvalue())
def suite():
"""loader."""
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -15,7 +15,6 @@
"""Tests for the 'beatport' plugin. """Tests for the 'beatport' plugin.
""" """
import unittest
from datetime import timedelta from datetime import timedelta
from beets.test import _common from beets.test import _common
@ -656,11 +655,3 @@ class BeatportResponseEmptyTest(BeetsTestCase):
self.assertEqual( self.assertEqual(
tracks[0].genre, self.test_tracks[0]["subGenres"][0]["name"] tracks[0].genre, self.test_tracks[0]["subGenres"][0]["name"]
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -15,8 +15,6 @@
"""Tests for the 'bucket' plugin.""" """Tests for the 'bucket' plugin."""
import unittest
from beets import config, ui from beets import config, ui
from beets.test.helper import BeetsTestCase from beets.test.helper import BeetsTestCase
from beetsplug import bucket from beetsplug import bucket
@ -165,11 +163,3 @@ class BucketPluginTest(BeetsTestCase):
self.check_span_from_str("1980 00", 1980, 2000) self.check_span_from_str("1980 00", 1980, 2000)
self.check_span_from_str("1930 00", 1930, 2000) self.check_span_from_str("1930 00", 1930, 2000)
self.check_span_from_str("1930 50", 1930, 1950) self.check_span_from_str("1930 50", 1930, 1950)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -343,11 +343,3 @@ class NeverConvertLossyFilesTest(ConvertTestCase, ConvertCommand):
self.run_convert_path(item.path) self.run_convert_path(item.path)
converted = os.path.join(self.convert_dest, b"converted.ogg") converted = os.path.join(self.convert_dest, b"converted.ogg")
self.assertNoFileTag(converted, "mp3") self.assertNoFileTag(converted, "mp3")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -15,7 +15,6 @@
"""Tests for discogs plugin. """Tests for discogs plugin.
""" """
import unittest
from beets import config from beets import config
from beets.test._common import Bag from beets.test._common import Bag
@ -424,11 +423,3 @@ class DGAlbumInfoTest(BeetsTestCase):
d = DiscogsPlugin().get_album_info(release) d = DiscogsPlugin().get_album_info(release)
self.assertEqual(d.genre, "GENRE1, GENRE2") self.assertEqual(d.genre, "GENRE1, GENRE2")
self.assertEqual(d.style, None) self.assertEqual(d.style, None)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,7 +13,6 @@
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
import codecs import codecs
import unittest
from unittest.mock import patch from unittest.mock import patch
from beets.dbcore.query import TrueQuery from beets.dbcore.query import TrueQuery
@ -514,11 +513,3 @@ class EditDuringImporterTestCase(
all("Edited Title " in i.title for i in self.lib.items()) all("Edited Title " in i.title for i in self.lib.items())
) )
self.assertTrue(all("match " in i.mb_trackid for i in self.lib.items())) self.assertTrue(all("match " in i.mb_trackid for i in self.lib.items()))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -339,11 +339,3 @@ class ArtSimilarityTest(unittest.TestCase):
def test_convert_failure(self, mock_extract, mock_subprocess): def test_convert_failure(self, mock_extract, mock_subprocess):
self._mock_popens(mock_extract, mock_subprocess, convert_status=1) self._mock_popens(mock_extract, mock_subprocess, convert_status=1)
self.assertIsNone(self._similarity(20)) self.assertIsNone(self._similarity(20))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,5 +1,3 @@
import unittest
import responses import responses
from beets.test.helper import PluginTestCase from beets.test.helper import PluginTestCase
@ -235,11 +233,3 @@ class EmbyUpdateTest(PluginTestCase):
self.assertEqual(response[0]["Id"], "2ec276a2642e54a19b612b9418a8bd3b") self.assertEqual(response[0]["Id"], "2ec276a2642e54a19b612b9418a8bd3b")
self.assertEqual(response[0]["Name"], "username") self.assertEqual(response[0]["Name"], "username")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -18,7 +18,6 @@
import json import json
import re # used to test csv format import re # used to test csv format
import unittest
from xml.etree import ElementTree from xml.etree import ElementTree
from xml.etree.ElementTree import Element from xml.etree.ElementTree import Element
@ -85,11 +84,3 @@ class ExportPluginTest(PluginTestCase):
txt = details.text txt = details.text
self.assertIn(tag, self.test_values, msg=tag) self.assertIn(tag, self.test_values, msg=tag)
self.assertEqual(self.test_values[tag], txt, msg=txt) self.assertEqual(self.test_values[tag], txt, msg=txt)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -16,7 +16,6 @@
import ctypes import ctypes
import os import os
import sys import sys
import unittest
from beets import util from beets import util
from beets.test.helper import PluginTestCase from beets.test.helper import PluginTestCase
@ -99,11 +98,3 @@ class FetchartCliTest(PluginTestCase):
self.run_command("fetchart") self.run_command("fetchart")
self.album.load() self.album.load()
self.check_cover_is_stored() self.check_cover_is_stored()
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -18,7 +18,6 @@
import os import os
import shutil import shutil
import unittest
from mediafile import MediaFile from mediafile import MediaFile
@ -217,11 +216,3 @@ class FileFilterPluginTest(ImportTestCase):
], ],
singletons=True, singletons=True,
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -169,11 +169,3 @@ class FtInTitlePluginTest(unittest.TestCase):
self.assertTrue(ftintitle.contains_feat("Alice With Bob")) self.assertTrue(ftintitle.contains_feat("Alice With Bob"))
self.assertFalse(ftintitle.contains_feat("Alice defeat Bob")) self.assertFalse(ftintitle.contains_feat("Alice defeat Bob"))
self.assertFalse(ftintitle.contains_feat("Aliceft.Bob")) self.assertFalse(ftintitle.contains_feat("Aliceft.Bob"))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -160,11 +160,3 @@ class HookTest(BeetsTestCase):
for path in temporary_paths: for path in temporary_paths:
self.assertTrue(os.path.isfile(path)) self.assertTrue(os.path.isfile(path))
os.remove(path) os.remove(path)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -43,11 +43,3 @@ class IHatePluginTest(unittest.TestCase):
"artist:testartist album:notthis", "artist:testartist album:notthis",
] ]
self.assertTrue(IHatePlugin.do_i_hate_this(task, match_pattern)) self.assertTrue(IHatePlugin.do_i_hate_this(task, match_pattern))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -16,7 +16,6 @@
"""Tests for the `importadded` plugin.""" """Tests for the `importadded` plugin."""
import os import os
import unittest
from beets import importer from beets import importer
from beets.test.helper import AutotagStub, ImportTestCase, PluginMixin from beets.test.helper import AutotagStub, ImportTestCase, PluginMixin
@ -167,11 +166,3 @@ class ImportAddedTest(PluginMixin, ImportTestCase):
"reimport modified Item.added for " "reimport modified Item.added for "
+ displayable_path(item_path), + displayable_path(item_path),
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,7 +1,6 @@
import datetime import datetime
import os import os
import os.path import os.path
import unittest
from beets import config from beets import config
from beets.library import Album, Item from beets.library import Album, Item
@ -67,11 +66,3 @@ class ImportfeedsTestTest(BeetsTestCase):
self.assertTrue(os.path.isfile(playlist)) self.assertTrue(os.path.isfile(playlist))
with open(playlist) as playlist_contents: with open(playlist) as playlist_contents:
self.assertIn(item_path, playlist_contents.read()) self.assertIn(item_path, playlist_contents.read())
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,8 +13,6 @@
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
import unittest
from mediafile import MediaFile from mediafile import MediaFile
from beets.test.helper import PluginTestCase from beets.test.helper import PluginTestCase
@ -118,11 +116,3 @@ class InfoTest(PluginTestCase):
"$track. $title - $artist ($length)", "$track. $title - $artist ($length)",
) )
self.assertEqual("02. tïtle 0 - the artist (0:01)\n", out) self.assertEqual("02. tïtle 0 - the artist (0:01)\n", out)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,7 +13,6 @@
import os import os
import unittest
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from beets.test import _common from beets.test import _common
@ -79,11 +78,3 @@ class IPFSPluginTest(PluginTestCase):
album.store(inherit=False) album.store(inherit=False)
return album return album
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,7 +13,6 @@
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
import unittest
from unittest.mock import patch from unittest.mock import patch
from beets import util from beets import util
@ -77,11 +76,3 @@ class KeyFinderTest(PluginTestCase):
item.load() item.load()
self.assertIsNone(item["initial_key"]) self.assertIsNone(item["initial_key"])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -15,7 +15,6 @@
"""Tests for the 'lastgenre' plugin.""" """Tests for the 'lastgenre' plugin."""
import unittest
from unittest.mock import Mock from unittest.mock import Mock
from beets import config from beets import config
@ -230,11 +229,3 @@ class LastGenrePluginTest(BeetsTestCase):
tags = ("electronic", "ambient", "chillout") tags = ("electronic", "ambient", "chillout")
res = self.plugin._sort_by_depth(tags) res = self.plugin._sort_by_depth(tags)
self.assertEqual(res, ["ambient", "electronic"]) self.assertEqual(res, ["ambient", "electronic"])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,7 +13,6 @@
"""Tests for the 'limit' plugin.""" """Tests for the 'limit' plugin."""
import unittest
from beets.test.helper import PluginTestCase from beets.test.helper import PluginTestCase
@ -94,11 +93,3 @@ class LimitPluginTest(PluginTestCase):
incorrect_order = self.num_limit_prefix + " " + self.track_tail_range incorrect_order = self.num_limit_prefix + " " + self.track_tail_range
result = self.lib.items(incorrect_order) result = self.lib.items(incorrect_order)
self.assertEqual(len(result), 0) self.assertEqual(len(result), 0)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -816,11 +816,3 @@ class SlugTests(unittest.TestCase):
dashes = ["\u200D", "\u2010"] dashes = ["\u200D", "\u2010"]
for dash1, dash2 in itertools.combinations(dashes, 2): for dash1, dash2 in itertools.combinations(dashes, 2):
self.assertEqual(lyrics.slug(dash1), lyrics.slug(dash2)) self.assertEqual(lyrics.slug(dash1), lyrics.slug(dash2))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,8 +13,6 @@
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
import unittest
from beets.test.helper import ( from beets.test.helper import (
AutotagStub, AutotagStub,
ImportTestCase, ImportTestCase,
@ -69,11 +67,3 @@ class MBSubmitPluginTest(PluginMixin, TerminalImportMixin, ImportTestCase):
"Open files with Picard? " "02. Tag Title 2 - Tag Artist (0:01)" "Open files with Picard? " "02. Tag Title 2 - Tag Artist (0:01)"
) )
self.assertIn(tracklist, output.getvalue()) self.assertIn(tracklist, output.getvalue())
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,7 +13,6 @@
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
import unittest
from unittest.mock import patch from unittest.mock import patch
from beets import config from beets import config
@ -188,11 +187,3 @@ class MbsyncCliTest(PluginTestCase):
self.run_command("mbsync", "-f", "'$title'") self.run_command("mbsync", "-f", "'$title'")
e = "mbsync: Skipping singleton with invalid mb_trackid: 'old title'" e = "mbsync: Skipping singleton with invalid mb_trackid: 'old title'"
self.assertEqual(e, logs[0]) self.assertEqual(e, logs[0])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -13,7 +13,6 @@
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
import unittest
from unittest.mock import ANY, Mock, call, patch from unittest.mock import ANY, Mock, call, patch
from beets import util from beets import util
@ -82,11 +81,3 @@ class MPDStatsTest(PluginTestCase):
log.info.assert_has_calls( log.info.assert_has_calls(
[call("pause"), call("playing {0}", ANY), call("stop")] [call("pause"), call("playing {0}", ANY), call("stop")]
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -232,11 +232,3 @@ class ParentWorkTest(PluginTestCase):
def test_direct_parent_work(self): def test_direct_parent_work(self):
self.assertEqual("2", parentwork.direct_parent_id("1")[0]) self.assertEqual("2", parentwork.direct_parent_id("1")[0])
self.assertEqual("3", parentwork.work_parent_id("1")[0]) self.assertEqual("3", parentwork.work_parent_id("1")[0])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -3,7 +3,6 @@
import os import os
import platform import platform
import unittest
from unittest.mock import Mock, patch from unittest.mock import Mock, patch
from beets.test._common import touch from beets.test._common import touch
@ -103,11 +102,3 @@ class PermissionsPluginTest(PluginTestCase):
self.assertEqual( self.assertEqual(
expect_success, check_permissions(album.artpath, 0o777) expect_success, check_permissions(album.artpath, 0o777)
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -141,11 +141,3 @@ class PlayPluginTest(CleanupModulesMixin, PluginTestCase):
with self.assertRaises(UserError): with self.assertRaises(UserError):
self.run_command("play", "title:aNiceTitle") self.run_command("play", "title:aNiceTitle")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1193,11 +1193,3 @@ class BPDPeersTest(BPDTestHelper):
}, },
expectedFailure=True, expectedFailure=True,
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -14,7 +14,6 @@
import os import os
import unittest
from shlex import quote from shlex import quote
import beets import beets
@ -387,11 +386,3 @@ class PlaylistTestItemRemoved(PlaylistUpdateTest, PlaylistTestCase):
"nonexisting.mp3", "nonexisting.mp3",
], ],
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,5 +1,3 @@
import unittest
import responses import responses
from beets.test.helper import PluginTestCase from beets.test.helper import PluginTestCase
@ -132,11 +130,3 @@ class PlexUpdateTest(PluginTestCase):
).status_code, ).status_code,
200, 200,
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -17,7 +17,6 @@
import os import os
import shutil import shutil
import unittest
import mediafile import mediafile
@ -124,11 +123,3 @@ class ExtendedFieldTestMixin(BeetsTestCase):
with self.assertRaises(ValueError) as cm: with self.assertRaises(ValueError) as cm:
mediafile.MediaFile.add_field("artist", mediafile.MediaField()) mediafile.MediaFile.add_field("artist", mediafile.MediaField())
self.assertIn('property "artist" already exists', str(cm.exception)) self.assertIn('property "artist" already exists', str(cm.exception))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -77,11 +77,3 @@ class RandomTest(TestHelper, unittest.TestCase):
self.assertAlmostEqual(0, median1, delta=1) self.assertAlmostEqual(0, median1, delta=1)
self.assertAlmostEqual(len(self.items) // 2, median2, delta=1) self.assertAlmostEqual(len(self.items) // 2, median2, delta=1)
self.assertGreater(stdev2, stdev1) self.assertGreater(stdev2, stdev1)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -392,12 +392,3 @@ class ReplayGainFfmpegThreadedImportTest(
ThreadedImportMixin, ImportTest, ReplayGainTestCase, FfmpegBackendMixin ThreadedImportMixin, ImportTest, ReplayGainTestCase, FfmpegBackendMixin
): ):
pass pass
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")
unittest.main(defaultTest="suite")

View file

@ -13,7 +13,6 @@
# included in all copies or substantial portions of the Software. # included in all copies or substantial portions of the Software.
import unittest
from os import fsdecode, path, remove from os import fsdecode, path, remove
from shutil import rmtree from shutil import rmtree
from tempfile import mkdtemp from tempfile import mkdtemp
@ -373,11 +372,3 @@ class SmartPlaylistCLITest(PluginTestCase):
for name in (b"my_playlist.m3u", b"all.m3u"): for name in (b"my_playlist.m3u", b"all.m3u"):
with open(path.join(self.temp_dir, name), "rb") as f: with open(path.join(self.temp_dir, name), "rb") as f:
self.assertEqual(f.read(), self.item.path + b"\n") self.assertEqual(f.read(), self.item.path + b"\n")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,7 +1,6 @@
"""Tests for the 'spotify' plugin""" """Tests for the 'spotify' plugin"""
import os import os
import unittest
from urllib.parse import parse_qs, urlparse from urllib.parse import parse_qs, urlparse
import responses import responses
@ -177,11 +176,3 @@ class SpotifyPluginTest(BeetsTestCase):
results = self.spotify._match_library_tracks(self.lib, "Happy") results = self.spotify._match_library_tracks(self.lib, "Happy")
self.assertEqual(1, len(results)) self.assertEqual(1, len(results))
self.assertEqual("6NPVjNh8Jhru9xOmyQigds", results[0]["id"]) self.assertEqual("6NPVjNh8Jhru9xOmyQigds", results[0]["id"])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,6 +1,5 @@
"""Tests for the 'subsonic' plugin.""" """Tests for the 'subsonic' plugin."""
import unittest
from urllib.parse import parse_qs, urlparse from urllib.parse import parse_qs, urlparse
import responses import responses
@ -183,12 +182,3 @@ class SubsonicPluginTest(BeetsTestCase):
) )
self.subsonicupdate.start_scan() self.subsonicupdate.start_scan()
def suite():
"""Default test suite."""
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,7 +1,5 @@
"""Tests for the 'the' plugin""" """Tests for the 'the' plugin"""
import unittest
from beets import config from beets import config
from beets.test.helper import BeetsTestCase from beets.test.helper import BeetsTestCase
from beetsplug.the import FORMAT, PATTERN_A, PATTERN_THE, ThePlugin from beetsplug.the import FORMAT, PATTERN_A, PATTERN_THE, ThePlugin
@ -61,11 +59,3 @@ class ThePluginTest(BeetsTestCase):
config["the"]["patterns"] = [PATTERN_THE, PATTERN_A] config["the"]["patterns"] = [PATTERN_THE, PATTERN_A]
config["the"]["format"] = "{1} ({0})" config["the"]["format"] = "{1} ({0})"
self.assertEqual(ThePlugin().the_template_func("The A"), "The (A)") self.assertEqual(ThePlugin().the_template_func("The A"), "The (A)")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -14,7 +14,6 @@
import os.path import os.path
import unittest
from shutil import rmtree from shutil import rmtree
from tempfile import mkdtemp from tempfile import mkdtemp
from unittest.mock import Mock, call, patch from unittest.mock import Mock, call, patch
@ -281,11 +280,3 @@ class TestPathlibURI:
# test it won't break if we pass it bytes for a path # test it won't break if we pass it bytes for a path
test_uri.uri(b"/") test_uri.uri(b"/")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -14,7 +14,6 @@
import time import time
import unittest
from datetime import datetime from datetime import datetime
from confuse import ConfigValueError from confuse import ConfigValueError
@ -193,11 +192,3 @@ class TypesPluginTest(PluginTestCase):
def mktime(*args): def mktime(*args):
return time.mktime(datetime(*args).timetuple()) return time.mktime(datetime(*args).timetuple())
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -4,7 +4,6 @@ import json
import os.path import os.path
import platform import platform
import shutil import shutil
import unittest
from beets import logging from beets import logging
from beets.library import Album, Item from beets.library import Album, Item
@ -677,11 +676,3 @@ class WebPluginTest(ItemInDBTestCase):
response = self.client.get("/item/" + str(item_id) + "/file") response = self.client.get("/item/" + str(item_id) + "/file")
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,7 +1,5 @@
"""Tests for the 'zero' plugin""" """Tests for the 'zero' plugin"""
import unittest
from mediafile import MediaFile from mediafile import MediaFile
from beets.library import Item from beets.library import Item
@ -292,11 +290,3 @@ class ZeroPluginTest(BeetsTestCase):
self.assertEqual(mf.year, 2016) self.assertEqual(mf.year, 2016)
self.assertEqual(mf.comments, "test comment") self.assertEqual(mf.comments, "test comment")
self.assertEqual(item["comments"], "test comment") self.assertEqual(item["comments"], "test comment")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -154,12 +154,3 @@ class ArtResizerFileSizeTest(CleanupModulesMixin, BeetsTestCase):
except AssertionError: except AssertionError:
command = im.convert_cmd + "foo -set b B -set a A foo".split() command = im.convert_cmd + "foo -set b B -set a A foo".split()
mock_util.command_output.assert_called_once_with(command) mock_util.command_output.assert_called_once_with(command)
def suite():
"""Run this suite of tests."""
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1088,11 +1088,3 @@ class EnumTest(BeetsTestCase):
self.assertGreater(OrderedEnumClass.b, OrderedEnumClass.a) self.assertGreater(OrderedEnumClass.b, OrderedEnumClass.a)
self.assertGreater(OrderedEnumClass.c, OrderedEnumClass.a) self.assertGreater(OrderedEnumClass.c, OrderedEnumClass.a)
self.assertGreater(OrderedEnumClass.c, OrderedEnumClass.b) self.assertGreater(OrderedEnumClass.c, OrderedEnumClass.b)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1,5 +1,4 @@
import os import os
import unittest
from unittest.mock import patch from unittest.mock import patch
import yaml import yaml
@ -128,11 +127,3 @@ class ConfigCommandTest(BeetsTestCase):
with patch("os.execlp") as execlp: with patch("os.execlp") as execlp:
self.run_command("config", "-e") self.run_command("config", "-e")
execlp.assert_called_once_with("myeditor", "myeditor", self.config_path) execlp.assert_called_once_with("myeditor", "myeditor", self.config_path)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -318,11 +318,3 @@ class DateQueryConstructTest(unittest.TestCase):
def test_datetime_invalid_separator(self): def test_datetime_invalid_separator(self):
with self.assertRaises(InvalidQueryArgumentValueError): with self.assertRaises(InvalidQueryArgumentValueError):
DateQuery("added", "2000-01-01x12") DateQuery("added", "2000-01-01x12")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -762,11 +762,3 @@ class ResultsIteratorTest(unittest.TestCase):
self.assertIsNone( self.assertIsNone(
self.db._fetch(ModelFixture1, dbcore.query.FalseQuery()).get() self.db._fetch(ModelFixture1, dbcore.query.FalseQuery()).get()
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -692,11 +692,3 @@ class MkDirAllTest(BeetsTestCase):
path = os.path.join(self.temp_dir, b"foo", b"bar", b"baz", b"qux.mp3") path = os.path.join(self.temp_dir, b"foo", b"bar", b"baz", b"qux.mp3")
util.mkdirall(path) util.mkdirall(path)
self.assertNotExists(path) self.assertNotExists(path)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -74,11 +74,3 @@ class HiddenFileTest(unittest.TestCase):
with tempfile.NamedTemporaryFile(prefix=".tmp") as f: with tempfile.NamedTemporaryFile(prefix=".tmp") as f:
fn = util.bytestring_path(f.name) fn = util.bytestring_path(f.name)
self.assertTrue(hidden.is_hidden(fn)) self.assertTrue(hidden.is_hidden(fn))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -2008,11 +2008,3 @@ class ImportMusicBrainzIdTest(ImportTestCase):
{"VALID_RECORDING_0", "VALID_RECORDING_1"}, {"VALID_RECORDING_0", "VALID_RECORDING_1"},
{c.info.title for c in task.candidates}, {c.info.title for c in task.candidates},
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1392,11 +1392,3 @@ class LibraryFieldTypesTest(unittest.TestCase):
beets.config["format_raw_length"] = True beets.config["format_raw_length"] = True
self.assertEqual(61.23, t.format(61.23)) self.assertEqual(61.23, t.format(61.23))
self.assertEqual(3601.23, t.format(3601.23)) self.assertEqual(3601.23, t.format(3601.23))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -3,7 +3,6 @@
import logging as log import logging as log
import sys import sys
import threading import threading
import unittest
from io import StringIO from io import StringIO
import beets.logging as blog import beets.logging as blog
@ -49,6 +48,7 @@ class LoggingTest(BeetsTestCase):
class LoggingLevelTest(PluginTestCase): class LoggingLevelTest(PluginTestCase):
plugin = "dummy" plugin = "dummy"
class DummyModule: class DummyModule:
class DummyPlugin(plugins.BeetsPlugin): class DummyPlugin(plugins.BeetsPlugin):
def __init__(self): def __init__(self):
@ -281,11 +281,3 @@ class ConcurrentEventsTest(BeetsTestCase):
importer = self.create_importer() importer = self.create_importer()
importer.run() importer.run()
self.assertIn("Sending event: database_change", logs) self.assertIn("Sending event: database_change", logs)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -148,12 +148,3 @@ class M3UFileTest(unittest.TestCase):
m3ufile = M3UFile(the_playlist_file) m3ufile = M3UFile(the_playlist_file)
m3ufile.load() m3ufile.load()
self.assertFalse(m3ufile.extm3u) self.assertFalse(m3ufile.extm3u)
def suite():
"""This testsuite's main function."""
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1077,11 +1077,3 @@ class MBLibraryTest(unittest.TestCase):
gp.side_effect = side_effect gp.side_effect = side_effect
album = mb.album_for_id("d2a6f856-b553-40a0-ac54-a321e8e2da02") album = mb.album_for_id("d2a6f856-b553-40a0-ac54-a321e8e2da02")
self.assertIsNone(album.country) self.assertIsNone(album.country)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -16,7 +16,6 @@
import os import os
import platform import platform
import time import time
import unittest
from datetime import datetime from datetime import datetime
from beets.library import Item from beets.library import Item
@ -128,11 +127,3 @@ class MetaSyncTest(PluginTestCase):
_parsetime("2014-04-24 09:28:38"), _parsetime("2014-04-24 09:28:38"),
) )
self.assertFalse(hasattr(self.lib.items()[1], "itunes_lastskipped")) self.assertFalse(hasattr(self.lib.items()[1], "itunes_lastskipped"))
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -230,11 +230,3 @@ class StageDecoratorTest(unittest.TestCase):
self.assertEqual( self.assertEqual(
list(pl.pull()), [{"x": True}, {"a": False, "x": True}] list(pl.pull()), [{"x": True}, {"a": False, "x": True}]
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -632,11 +632,3 @@ class ParseBeatportIDTest(unittest.TestCase):
id_url = "https://www.beatport.com/release/album-name/%s" % id_string id_url = "https://www.beatport.com/release/album-name/%s" % id_string
out = MetadataSourcePlugin._get_id("album", id_url, beatport_id_regex) out = MetadataSourcePlugin._get_id("album", id_url, beatport_id_regex)
self.assertEqual(out, id_string) self.assertEqual(out, id_string)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1161,11 +1161,3 @@ class RelatedQueriesTest(BeetsTestCase, AssertsMixin):
q = "catalognum:ABC Album1" q = "catalognum:ABC Album1"
results = self.lib.albums(q) results = self.lib.albums(q)
self.assert_albums_matched(results, ["Album1"]) self.assert_albums_matched(results, ["Album1"])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -15,7 +15,6 @@
"""Various tests for querying the library database. """Various tests for querying the library database.
""" """
import unittest
import beets.library import beets.library
from beets import config, dbcore from beets import config, dbcore
@ -531,11 +530,3 @@ class NonExistingFieldTest(DummyDataTestCase):
self.assertTrue(isinstance(query.subqueries[0], dbcore.query.TrueQuery)) self.assertTrue(isinstance(query.subqueries[0], dbcore.query.TrueQuery))
self.assertTrue(isinstance(sort, dbcore.query.SlowFieldSort)) self.assertTrue(isinstance(sort, dbcore.query.SlowFieldSort))
self.assertEqual(sort.field, "-bar") self.assertEqual(sort.field, "-bar")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -290,11 +290,3 @@ class EvalTest(unittest.TestCase):
def test_function_call_with_empty_arg(self): def test_function_call_with_empty_arg(self):
self.assertEqual(self._eval("%len{}"), "0") self.assertEqual(self._eval("%len{}"), "0")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -1648,11 +1648,3 @@ class EncodingTest(BeetsTestCase):
with patch("sys.stdin") as stdin: with patch("sys.stdin") as stdin:
stdin.encoding = None stdin.encoding = None
self.assertEqual(ui._in_encoding(), "utf-8") self.assertEqual(ui._in_encoding(), "utf-8")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -18,7 +18,6 @@
import os import os
import shutil import shutil
import unittest
from beets import library, ui from beets import library, ui
from beets.test import _common from beets.test import _common
@ -104,11 +103,3 @@ class FieldsTest(ItemInDBTestCase):
self.assertEqual(len(items), 0) self.assertEqual(len(items), 0)
self.assertEqual(len(albums), 0) self.assertEqual(len(albums), 0)
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -18,7 +18,6 @@ test_importer module. But here the test importer inherits from
``TerminalImportSession``. So we test this class, too. ``TerminalImportSession``. So we test this class, too.
""" """
import unittest
from test import test_importer from test import test_importer
from beets.test.helper import TerminalImportMixin from beets.test.helper import TerminalImportMixin
@ -70,11 +69,3 @@ class GlobalGroupAlbumsImportTest(
TerminalImportMixin, test_importer.GlobalGroupAlbumsImportTest TerminalImportMixin, test_importer.GlobalGroupAlbumsImportTest
): ):
pass pass
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -17,7 +17,6 @@
import os import os
import shutil import shutil
import unittest
from copy import deepcopy from copy import deepcopy
from random import random from random import random
@ -160,11 +159,3 @@ class ParentalDirCreation(BeetsTestCase):
if lib: if lib:
lib._close() lib._close()
raise OSError("Parent directories should not be created.") raise OSError("Parent directories should not be created.")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -216,11 +216,3 @@ class PathTruncationTest(BeetsTestCase):
with _common.platform_posix(): with _common.platform_posix():
p = util.truncate_path("abcde/fgh.ext", 5) p = util.truncate_path("abcde/fgh.ext", 5)
self.assertEqual(p, "abcde/f.ext") self.assertEqual(p, "abcde/f.ext")
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -14,7 +14,6 @@
"""Tests for the virtual filesystem builder..""" """Tests for the virtual filesystem builder.."""
import unittest
from beets import vfs from beets import vfs
from beets.test import _common from beets.test import _common
@ -41,11 +40,3 @@ class VFSTest(BeetsTestCase):
self.assertEqual( self.assertEqual(
self.tree.dirs["albums"].dirs["the album"].files["the title"], 2 self.tree.dirs["albums"].dirs["the album"].files["the title"], 2
) )
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)
if __name__ == "__main__":
unittest.main(defaultTest="suite")

View file

@ -16,25 +16,7 @@
import os import os
import re
import sys import sys
import unittest
pkgpath = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) or ".." pkgpath = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) or ".."
sys.path.insert(0, pkgpath) sys.path.insert(0, pkgpath)
def suite():
s = unittest.TestSuite()
# Get the suite() of every module in this directory beginning with
# "test_".
for fname in os.listdir(os.path.join(pkgpath, "test")):
match = re.match(r"(test_\S+)\.py$", fname)
if match:
modname = match.group(1)
s.addTest(__import__(modname).suite())
return s
if __name__ == "__main__":
unittest.main(defaultTest="suite")