mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Replace assertIsFile
This commit is contained in:
parent
038843cdb2
commit
ca4fa6ba10
2 changed files with 8 additions and 8 deletions
|
|
@ -115,11 +115,6 @@ 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 assertIsFile(self, path):
|
|
||||||
path = Path(os.fsdecode(path))
|
|
||||||
assert path.exists()
|
|
||||||
assert path.is_file()
|
|
||||||
|
|
||||||
def assertIsDir(self, path):
|
def assertIsDir(self, path):
|
||||||
path = Path(os.fsdecode(path))
|
path = Path(os.fsdecode(path))
|
||||||
assert path.exists()
|
assert path.exists()
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,18 @@ class ConvertMixin:
|
||||||
shell_quote(sys.executable), shell_quote(stub), tag
|
shell_quote(sys.executable), shell_quote(stub), tag
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def assert_is_file(self, path):
|
||||||
|
path = Path(os.fsdecode(path))
|
||||||
|
assert path.exists()
|
||||||
|
assert path.is_file()
|
||||||
|
|
||||||
def assertFileTag(self, path, tag):
|
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`.
|
||||||
"""
|
"""
|
||||||
display_tag = tag
|
display_tag = tag
|
||||||
tag = tag.encode("utf-8")
|
tag = tag.encode("utf-8")
|
||||||
self.assertIsFile(path)
|
self.assert_is_file(path)
|
||||||
with open(path, "rb") as f:
|
with open(path, "rb") as f:
|
||||||
f.seek(-len(display_tag), os.SEEK_END)
|
f.seek(-len(display_tag), os.SEEK_END)
|
||||||
assert f.read() == tag, (
|
assert f.read() == tag, (
|
||||||
|
|
@ -77,7 +82,7 @@ class ConvertMixin:
|
||||||
"""
|
"""
|
||||||
display_tag = tag
|
display_tag = tag
|
||||||
tag = tag.encode("utf-8")
|
tag = tag.encode("utf-8")
|
||||||
self.assertIsFile(path)
|
self.assert_is_file(path)
|
||||||
with open(path, "rb") as f:
|
with open(path, "rb") as f:
|
||||||
f.seek(-len(tag), os.SEEK_END)
|
f.seek(-len(tag), os.SEEK_END)
|
||||||
assert f.read() != tag, (
|
assert f.read() != tag, (
|
||||||
|
|
@ -117,7 +122,7 @@ class ImportConvertTest(AsIsImporterMixin, ImportHelper, ConvertTestCase):
|
||||||
|
|
||||||
item = self.lib.items().get()
|
item = self.lib.items().get()
|
||||||
assert item is not None
|
assert item is not None
|
||||||
self.assertIsFile(item.path)
|
self.assert_is_file(item.path)
|
||||||
|
|
||||||
def test_delete_originals(self):
|
def test_delete_originals(self):
|
||||||
self.config["convert"]["delete_originals"] = True
|
self.config["convert"]["delete_originals"] = True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue