mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 16:42:42 +01:00
Remove some lint exclusions and fix the issues
* Replace `noqa` comments in `assert...` method definitions with a configuration option to ignore these names. * Use the `__all__` variable to specify importable items from the module, replacing `*` imports and `noqa` comments for unused imports. * Address issues with poorly named variables and methods by renaming them appropriately.
This commit is contained in:
parent
f36bc497c8
commit
5f78d1b82b
15 changed files with 92 additions and 58 deletions
|
|
@ -371,7 +371,7 @@ class Distance:
|
||||||
self.tracks: Dict[TrackInfo, Distance] = {}
|
self.tracks: Dict[TrackInfo, Distance] = {}
|
||||||
|
|
||||||
@cached_classproperty
|
@cached_classproperty
|
||||||
def _weights(cls) -> Dict[str, float]: # noqa: N805
|
def _weights(cls) -> Dict[str, float]:
|
||||||
"""A dictionary from keys to floating-point weights."""
|
"""A dictionary from keys to floating-point weights."""
|
||||||
weights_view = config["match"]["distance_weights"]
|
weights_view = config["match"]["distance_weights"]
|
||||||
weights = {}
|
weights = {}
|
||||||
|
|
|
||||||
|
|
@ -32,4 +32,18 @@ from .queryparse import (
|
||||||
)
|
)
|
||||||
from .types import Type
|
from .types import Type
|
||||||
|
|
||||||
# flake8: noqa
|
__all__ = [
|
||||||
|
"AndQuery",
|
||||||
|
"Database",
|
||||||
|
"FieldQuery",
|
||||||
|
"InvalidQueryError",
|
||||||
|
"MatchQuery",
|
||||||
|
"Model",
|
||||||
|
"OrQuery",
|
||||||
|
"Query",
|
||||||
|
"Results",
|
||||||
|
"Type",
|
||||||
|
"parse_sorted_query",
|
||||||
|
"query_from_strings",
|
||||||
|
"sort_from_strings",
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,34 @@ use {}-style formatting and can interpolate keywords arguments to the logging
|
||||||
calls (`debug`, `info`, etc).
|
calls (`debug`, `info`, etc).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
|
||||||
import threading
|
import threading
|
||||||
from copy import copy
|
from copy import copy
|
||||||
|
from logging import (
|
||||||
|
DEBUG,
|
||||||
|
INFO,
|
||||||
|
NOTSET,
|
||||||
|
WARNING,
|
||||||
|
FileHandler,
|
||||||
|
Filter,
|
||||||
|
Handler,
|
||||||
|
Logger,
|
||||||
|
NullHandler,
|
||||||
|
StreamHandler,
|
||||||
|
)
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"DEBUG",
|
||||||
|
"INFO",
|
||||||
|
"NOTSET",
|
||||||
|
"WARNING",
|
||||||
|
"FileHandler",
|
||||||
|
"Filter",
|
||||||
|
"Handler",
|
||||||
|
"Logger",
|
||||||
|
"NullHandler",
|
||||||
|
"StreamHandler",
|
||||||
|
"getLogger",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def logsafe(val):
|
def logsafe(val):
|
||||||
|
|
@ -45,7 +70,7 @@ def logsafe(val):
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
class StrFormatLogger(logging.Logger):
|
class StrFormatLogger(Logger):
|
||||||
"""A version of `Logger` that uses `str.format`-style formatting
|
"""A version of `Logger` that uses `str.format`-style formatting
|
||||||
instead of %-style formatting and supports keyword arguments.
|
instead of %-style formatting and supports keyword arguments.
|
||||||
|
|
||||||
|
|
@ -95,12 +120,12 @@ class StrFormatLogger(logging.Logger):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ThreadLocalLevelLogger(logging.Logger):
|
class ThreadLocalLevelLogger(Logger):
|
||||||
"""A version of `Logger` whose level is thread-local instead of shared."""
|
"""A version of `Logger` whose level is thread-local instead of shared."""
|
||||||
|
|
||||||
def __init__(self, name, level=logging.NOTSET):
|
def __init__(self, name, level=NOTSET):
|
||||||
self._thread_level = threading.local()
|
self._thread_level = threading.local()
|
||||||
self.default_level = logging.NOTSET
|
self.default_level = NOTSET
|
||||||
super().__init__(name, level)
|
super().__init__(name, level)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
@ -127,17 +152,13 @@ class BeetsLogger(ThreadLocalLevelLogger, StrFormatLogger):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
my_manager = copy(logging.Logger.manager)
|
my_manager = copy(Logger.manager)
|
||||||
my_manager.loggerClass = BeetsLogger
|
my_manager.loggerClass = BeetsLogger
|
||||||
|
|
||||||
|
|
||||||
# Act like the stdlib logging module by re-exporting its namespace.
|
|
||||||
from logging import * # noqa
|
|
||||||
|
|
||||||
|
|
||||||
# Override the `getLogger` to use our machinery.
|
# Override the `getLogger` to use our machinery.
|
||||||
def getLogger(name=None): # noqa
|
def getLogger(name=None): # noqa
|
||||||
if name:
|
if name:
|
||||||
return my_manager.getLogger(name)
|
return my_manager.getLogger(name)
|
||||||
else:
|
else:
|
||||||
return logging.Logger.root
|
return Logger.root
|
||||||
|
|
|
||||||
|
|
@ -143,19 +143,19 @@ def import_session(lib=None, loghandler=None, paths=[], query=[], cli=False):
|
||||||
class Assertions:
|
class Assertions:
|
||||||
"""A mixin with additional unit test assertions."""
|
"""A mixin with additional unit test assertions."""
|
||||||
|
|
||||||
def assertExists(self, path): # noqa
|
def assertExists(self, path):
|
||||||
assert os.path.exists(syspath(path)), f"file does not exist: {path!r}"
|
assert os.path.exists(syspath(path)), f"file does not exist: {path!r}"
|
||||||
|
|
||||||
def assertNotExists(self, path): # noqa
|
def assertNotExists(self, path):
|
||||||
assert not os.path.exists(syspath(path)), f"file exists: {path!r}"
|
assert not os.path.exists(syspath(path)), f"file exists: {path!r}"
|
||||||
|
|
||||||
def assertIsFile(self, path): # noqa
|
def assertIsFile(self, path):
|
||||||
self.assertExists(path)
|
self.assertExists(path)
|
||||||
assert os.path.isfile(
|
assert os.path.isfile(
|
||||||
syspath(path)
|
syspath(path)
|
||||||
), "path exists, but is not a regular file: {!r}".format(path)
|
), "path exists, but is not a regular file: {!r}".format(path)
|
||||||
|
|
||||||
def assertIsDir(self, path): # noqa
|
def assertIsDir(self, path):
|
||||||
self.assertExists(path)
|
self.assertExists(path)
|
||||||
assert os.path.isdir(
|
assert os.path.isdir(
|
||||||
syspath(path)
|
syspath(path)
|
||||||
|
|
|
||||||
|
|
@ -1069,7 +1069,7 @@ def par_map(transform: Callable[[T], Any], items: Sequence[T]) -> None:
|
||||||
pool.join()
|
pool.join()
|
||||||
|
|
||||||
|
|
||||||
class cached_classproperty: # noqa: N801
|
class cached_classproperty:
|
||||||
"""A decorator implementing a read-only property that is *lazy* in
|
"""A decorator implementing a read-only property that is *lazy* in
|
||||||
the sense that the getter is only invoked once. Subsequent accesses
|
the sense that the getter is only invoked once. Subsequent accesses
|
||||||
through *any* instance use the cached result.
|
through *any* instance use the cached result.
|
||||||
|
|
|
||||||
|
|
@ -738,13 +738,13 @@ class BaseServer:
|
||||||
|
|
||||||
# Additions to the MPD protocol.
|
# Additions to the MPD protocol.
|
||||||
|
|
||||||
def cmd_crash_TypeError(self, conn): # noqa: N802
|
def cmd_crash(self, conn):
|
||||||
"""Deliberately trigger a TypeError for testing purposes.
|
"""Deliberately trigger a TypeError for testing purposes.
|
||||||
We want to test that the server properly responds with ERROR_SYSTEM
|
We want to test that the server properly responds with ERROR_SYSTEM
|
||||||
without crashing, and that this is not treated as ERROR_ARG (since it
|
without crashing, and that this is not treated as ERROR_ARG (since it
|
||||||
is caused by a programming error, not a protocol error).
|
is caused by a programming error, not a protocol error).
|
||||||
"""
|
"""
|
||||||
"a" + 2
|
raise TypeError
|
||||||
|
|
||||||
|
|
||||||
class Connection:
|
class Connection:
|
||||||
|
|
|
||||||
|
|
@ -260,3 +260,4 @@ ignore-variadic-names = true
|
||||||
|
|
||||||
[tool.ruff.lint.pep8-naming]
|
[tool.ruff.lint.pep8-naming]
|
||||||
classmethod-decorators = ["cached_classproperty"]
|
classmethod-decorators = ["cached_classproperty"]
|
||||||
|
extend-ignore-names = ["assert*", "cached_classproperty"]
|
||||||
|
|
|
||||||
|
|
@ -865,7 +865,7 @@ class ArtForAlbumTest(UseThePlugin):
|
||||||
fetchart.FileSystem.get = self.old_fs_source_get
|
fetchart.FileSystem.get = self.old_fs_source_get
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
|
||||||
def _assertImageIsValidArt(self, image_file, should_exist): # noqa
|
def assertImageIsValidArt(self, image_file, should_exist):
|
||||||
self.assertExists(image_file)
|
self.assertExists(image_file)
|
||||||
self.image_file = image_file
|
self.image_file = image_file
|
||||||
|
|
||||||
|
|
@ -896,42 +896,42 @@ class ArtForAlbumTest(UseThePlugin):
|
||||||
def test_respect_minwidth(self):
|
def test_respect_minwidth(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
self.plugin.minwidth = 300
|
self.plugin.minwidth = 300
|
||||||
self._assertImageIsValidArt(self.IMG_225x225, False)
|
self.assertImageIsValidArt(self.IMG_225x225, False)
|
||||||
self._assertImageIsValidArt(self.IMG_348x348, True)
|
self.assertImageIsValidArt(self.IMG_348x348, True)
|
||||||
|
|
||||||
def test_respect_enforce_ratio_yes(self):
|
def test_respect_enforce_ratio_yes(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
self.plugin.enforce_ratio = True
|
self.plugin.enforce_ratio = True
|
||||||
self._assertImageIsValidArt(self.IMG_500x490, False)
|
self.assertImageIsValidArt(self.IMG_500x490, False)
|
||||||
self._assertImageIsValidArt(self.IMG_225x225, True)
|
self.assertImageIsValidArt(self.IMG_225x225, True)
|
||||||
|
|
||||||
def test_respect_enforce_ratio_no(self):
|
def test_respect_enforce_ratio_no(self):
|
||||||
self.plugin.enforce_ratio = False
|
self.plugin.enforce_ratio = False
|
||||||
self._assertImageIsValidArt(self.IMG_500x490, True)
|
self.assertImageIsValidArt(self.IMG_500x490, True)
|
||||||
|
|
||||||
def test_respect_enforce_ratio_px_above(self):
|
def test_respect_enforce_ratio_px_above(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
self.plugin.enforce_ratio = True
|
self.plugin.enforce_ratio = True
|
||||||
self.plugin.margin_px = 5
|
self.plugin.margin_px = 5
|
||||||
self._assertImageIsValidArt(self.IMG_500x490, False)
|
self.assertImageIsValidArt(self.IMG_500x490, False)
|
||||||
|
|
||||||
def test_respect_enforce_ratio_px_below(self):
|
def test_respect_enforce_ratio_px_below(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
self.plugin.enforce_ratio = True
|
self.plugin.enforce_ratio = True
|
||||||
self.plugin.margin_px = 15
|
self.plugin.margin_px = 15
|
||||||
self._assertImageIsValidArt(self.IMG_500x490, True)
|
self.assertImageIsValidArt(self.IMG_500x490, True)
|
||||||
|
|
||||||
def test_respect_enforce_ratio_percent_above(self):
|
def test_respect_enforce_ratio_percent_above(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
self.plugin.enforce_ratio = True
|
self.plugin.enforce_ratio = True
|
||||||
self.plugin.margin_percent = (500 - 490) / 500 * 0.5
|
self.plugin.margin_percent = (500 - 490) / 500 * 0.5
|
||||||
self._assertImageIsValidArt(self.IMG_500x490, False)
|
self.assertImageIsValidArt(self.IMG_500x490, False)
|
||||||
|
|
||||||
def test_respect_enforce_ratio_percent_below(self):
|
def test_respect_enforce_ratio_percent_below(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
self.plugin.enforce_ratio = True
|
self.plugin.enforce_ratio = True
|
||||||
self.plugin.margin_percent = (500 - 490) / 500 * 1.5
|
self.plugin.margin_percent = (500 - 490) / 500 * 1.5
|
||||||
self._assertImageIsValidArt(self.IMG_500x490, True)
|
self.assertImageIsValidArt(self.IMG_500x490, True)
|
||||||
|
|
||||||
def test_resize_if_necessary(self):
|
def test_resize_if_necessary(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
|
|
@ -948,7 +948,7 @@ class ArtForAlbumTest(UseThePlugin):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
self.plugin.max_filesize = self.IMG_225x225_SIZE
|
self.plugin.max_filesize = self.IMG_225x225_SIZE
|
||||||
self._assert_image_operated(self.IMG_225x225, self.RESIZE_OP, False)
|
self._assert_image_operated(self.IMG_225x225, self.RESIZE_OP, False)
|
||||||
self._assertImageIsValidArt(self.IMG_225x225, True)
|
self.assertImageIsValidArt(self.IMG_225x225, True)
|
||||||
|
|
||||||
def test_fileresize_no_scale(self):
|
def test_fileresize_no_scale(self):
|
||||||
self._require_backend()
|
self._require_backend()
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class ConvertMixin:
|
||||||
shell_quote(sys.executable), shell_quote(stub), tag
|
shell_quote(sys.executable), shell_quote(stub), tag
|
||||||
)
|
)
|
||||||
|
|
||||||
def assertFileTag(self, path, tag): # noqa
|
def assertFileTag(self, path, tag):
|
||||||
"""Assert that the path is a file and the files content ends
|
"""Assert that the path is a file and the files content ends
|
||||||
with `tag`.
|
with `tag`.
|
||||||
"""
|
"""
|
||||||
|
|
@ -68,7 +68,7 @@ class ConvertMixin:
|
||||||
f.read() == tag
|
f.read() == tag
|
||||||
), f"{displayable_path(path)} is not tagged with {display_tag}"
|
), f"{displayable_path(path)} is not tagged with {display_tag}"
|
||||||
|
|
||||||
def assertNoFileTag(self, path, tag): # noqa
|
def assertNoFileTag(self, path, tag):
|
||||||
"""Assert that the path is a file and the files content does not
|
"""Assert that the path is a file and the files content does not
|
||||||
end with `tag`.
|
end with `tag`.
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class EditMixin(PluginMixin):
|
||||||
|
|
||||||
plugin = "edit"
|
plugin = "edit"
|
||||||
|
|
||||||
def assertItemFieldsModified( # noqa
|
def assertItemFieldsModified(
|
||||||
self, library_items, items, fields=[], allowed=["path"]
|
self, library_items, items, fields=[], allowed=["path"]
|
||||||
):
|
):
|
||||||
"""Assert that items in the library (`lib_items`) have different values
|
"""Assert that items in the library (`lib_items`) have different values
|
||||||
|
|
@ -134,7 +134,7 @@ class EditCommandTest(EditMixin, BeetsTestCase):
|
||||||
{f: item[f] for f in item._fields} for item in self.album.items()
|
{f: item[f] for f in item._fields} for item in self.album.items()
|
||||||
]
|
]
|
||||||
|
|
||||||
def assertCounts( # noqa
|
def assertCounts(
|
||||||
self,
|
self,
|
||||||
mock_write,
|
mock_write,
|
||||||
album_count=ALBUM_COUNT,
|
album_count=ALBUM_COUNT,
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,11 @@ class ImportAddedTest(PluginMixin, ImportTestCase):
|
||||||
"No MediaFile found for Item " + displayable_path(item.path)
|
"No MediaFile found for Item " + displayable_path(item.path)
|
||||||
)
|
)
|
||||||
|
|
||||||
def assertEqualTimes(self, first, second, msg=None): # noqa
|
def assertEqualTimes(self, first, second, msg=None):
|
||||||
"""For comparing file modification times at a sufficient precision"""
|
"""For comparing file modification times at a sufficient precision"""
|
||||||
assert first == pytest.approx(second, rel=1e-4), msg
|
assert first == pytest.approx(second, rel=1e-4), msg
|
||||||
|
|
||||||
def assertAlbumImport(self): # noqa
|
def assertAlbumImport(self):
|
||||||
self.importer.run()
|
self.importer.run()
|
||||||
album = self.lib.albums().get()
|
album = self.lib.albums().get()
|
||||||
assert album.added == self.min_mtime
|
assert album.added == self.min_mtime
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class PermissionsPluginTest(AsIsImporterMixin, PluginMixin, ImportTestCase):
|
||||||
for path in dirs_in_library(self.lib.directory, item.path):
|
for path in dirs_in_library(self.lib.directory, item.path):
|
||||||
self.assertPerms(path, "dir", expect_success)
|
self.assertPerms(path, "dir", expect_success)
|
||||||
|
|
||||||
def assertPerms(self, path, typ, expect_success): # noqa
|
def assertPerms(self, path, typ, expect_success):
|
||||||
for x in [
|
for x in [
|
||||||
(True, self.exp_perms[expect_success][typ], "!="),
|
(True, self.exp_perms[expect_success][typ], "!="),
|
||||||
(False, self.exp_perms[not expect_success][typ], "=="),
|
(False, self.exp_perms[not expect_success][typ], "=="),
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ gstplayer = importlib.util.module_from_spec(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _gstplayer_play(*_): # noqa: 42
|
def _gstplayer_play(*_):
|
||||||
bpd.gstplayer._GstPlayer.playing = True
|
bpd.gstplayer._GstPlayer.playing = True
|
||||||
return mock.DEFAULT
|
return mock.DEFAULT
|
||||||
|
|
||||||
|
|
@ -242,7 +242,7 @@ class MPCClient:
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
def implements(commands, expectedFailure=False): # noqa: N803
|
def implements(commands, fail=False):
|
||||||
def _test(self):
|
def _test(self):
|
||||||
with self.run_bpd() as client:
|
with self.run_bpd() as client:
|
||||||
response = client.send_command("commands")
|
response = client.send_command("commands")
|
||||||
|
|
@ -250,7 +250,7 @@ def implements(commands, expectedFailure=False): # noqa: N803
|
||||||
implemented = response.data["command"]
|
implemented = response.data["command"]
|
||||||
assert commands.intersection(implemented) == commands
|
assert commands.intersection(implemented) == commands
|
||||||
|
|
||||||
return unittest.expectedFailure(_test) if expectedFailure else _test
|
return unittest.expectedFailure(_test) if fail else _test
|
||||||
|
|
||||||
|
|
||||||
bluelet_listener = bluelet.Listener
|
bluelet_listener = bluelet.Listener
|
||||||
|
|
@ -437,7 +437,7 @@ class BPDTest(BPDTestHelper):
|
||||||
|
|
||||||
def test_system_error(self):
|
def test_system_error(self):
|
||||||
with self.run_bpd() as client:
|
with self.run_bpd() as client:
|
||||||
response = client.send_command("crash_TypeError")
|
response = client.send_command("crash")
|
||||||
self._assert_failed(response, bpd.ERROR_SYSTEM)
|
self._assert_failed(response, bpd.ERROR_SYSTEM)
|
||||||
|
|
||||||
def test_empty_request(self):
|
def test_empty_request(self):
|
||||||
|
|
@ -763,7 +763,7 @@ class BPDControlTest(BPDTestHelper):
|
||||||
"seekid",
|
"seekid",
|
||||||
"seekcur",
|
"seekcur",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_cmd_play(self):
|
def test_cmd_play(self):
|
||||||
|
|
@ -873,7 +873,7 @@ class BPDQueueTest(BPDTestHelper):
|
||||||
"addtagid",
|
"addtagid",
|
||||||
"cleartagid",
|
"cleartagid",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
METADATA = {"Pos", "Time", "Id", "file", "duration"}
|
METADATA = {"Pos", "Time", "Id", "file", "duration"}
|
||||||
|
|
@ -990,7 +990,7 @@ class BPDDatabaseTest(BPDTestHelper):
|
||||||
"update",
|
"update",
|
||||||
"rescan",
|
"rescan",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_cmd_search(self):
|
def test_cmd_search(self):
|
||||||
|
|
@ -1050,7 +1050,7 @@ class BPDMountsTest(BPDTestHelper):
|
||||||
"listmounts",
|
"listmounts",
|
||||||
"listneighbors",
|
"listneighbors",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1059,7 +1059,7 @@ class BPDStickerTest(BPDTestHelper):
|
||||||
{
|
{
|
||||||
"sticker",
|
"sticker",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1142,7 +1142,7 @@ class BPDPartitionTest(BPDTestHelper):
|
||||||
"listpartitions",
|
"listpartitions",
|
||||||
"newpartition",
|
"newpartition",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1154,7 +1154,7 @@ class BPDDeviceTest(BPDTestHelper):
|
||||||
"toggleoutput",
|
"toggleoutput",
|
||||||
"outputs",
|
"outputs",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1166,7 +1166,7 @@ class BPDReflectionTest(BPDTestHelper):
|
||||||
"notcommands",
|
"notcommands",
|
||||||
"urlhandlers",
|
"urlhandlers",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_cmd_decoders(self):
|
def test_cmd_decoders(self):
|
||||||
|
|
@ -1187,5 +1187,5 @@ class BPDPeersTest(BPDTestHelper):
|
||||||
"readmessages",
|
"readmessages",
|
||||||
"sendmessage",
|
"sendmessage",
|
||||||
},
|
},
|
||||||
expectedFailure=True,
|
fail=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -133,16 +133,14 @@ class DateIntervalTest(unittest.TestCase):
|
||||||
self.assertContains("..", date=datetime.min)
|
self.assertContains("..", date=datetime.min)
|
||||||
self.assertContains("..", "1000-01-01T00:00:00")
|
self.assertContains("..", "1000-01-01T00:00:00")
|
||||||
|
|
||||||
def assertContains( # noqa
|
def assertContains(self, interval_pattern, date_pattern=None, date=None):
|
||||||
self, interval_pattern, date_pattern=None, date=None
|
|
||||||
):
|
|
||||||
if date is None:
|
if date is None:
|
||||||
date = _date(date_pattern)
|
date = _date(date_pattern)
|
||||||
(start, end) = _parse_periods(interval_pattern)
|
(start, end) = _parse_periods(interval_pattern)
|
||||||
interval = DateInterval.from_periods(start, end)
|
interval = DateInterval.from_periods(start, end)
|
||||||
assert interval.contains(date)
|
assert interval.contains(date)
|
||||||
|
|
||||||
def assertExcludes(self, interval_pattern, date_pattern): # noqa
|
def assertExcludes(self, interval_pattern, date_pattern):
|
||||||
date = _date(date_pattern)
|
date = _date(date_pattern)
|
||||||
(start, end) = _parse_periods(interval_pattern)
|
(start, end) = _parse_periods(interval_pattern)
|
||||||
interval = DateInterval.from_periods(start, end)
|
interval = DateInterval.from_periods(start, end)
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,11 @@ class AssertsMixin:
|
||||||
def assert_albums_matched(self, results, albums):
|
def assert_albums_matched(self, results, albums):
|
||||||
assert {a.album for a in results} == set(albums)
|
assert {a.album for a in results} == set(albums)
|
||||||
|
|
||||||
def assertInResult(self, item, results): # noqa
|
def assertInResult(self, item, results):
|
||||||
result_ids = [i.id for i in results]
|
result_ids = [i.id for i in results]
|
||||||
assert item.id in result_ids
|
assert item.id in result_ids
|
||||||
|
|
||||||
def assertNotInResult(self, item, results): # noqa
|
def assertNotInResult(self, item, results):
|
||||||
result_ids = [i.id for i in results]
|
result_ids = [i.id for i in results]
|
||||||
assert item.id not in result_ids
|
assert item.id not in result_ids
|
||||||
|
|
||||||
|
|
@ -927,7 +927,7 @@ class NotQueryTest(DummyDataTestCase):
|
||||||
- `test_get_yyy`: tests on query strings (similar to `GetTest`)
|
- `test_get_yyy`: tests on query strings (similar to `GetTest`)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def assertNegationProperties(self, q): # noqa
|
def assertNegationProperties(self, q):
|
||||||
"""Given a Query `q`, assert that:
|
"""Given a Query `q`, assert that:
|
||||||
- q OR not(q) == all items
|
- q OR not(q) == all items
|
||||||
- q AND not(q) == 0
|
- q AND not(q) == 0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue