From 0696f915e5bcf48e0aa1836d9cba6174ac355214 Mon Sep 17 00:00:00 2001 From: Reg Date: Thu, 20 Dec 2018 18:37:34 +0100 Subject: [PATCH] test_fetchart: Avoid duplicate code in future tests. --- test/test_fetchart.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/test_fetchart.py b/test/test_fetchart.py index 91bc34101..a3c783766 100644 --- a/test/test_fetchart.py +++ b/test/test_fetchart.py @@ -29,21 +29,24 @@ class FetchartCliTest(unittest.TestCase, TestHelper): self.config['fetchart']['cover_names'] = 'c\xc3\xb6ver.jpg' self.config['art_filename'] = 'mycover' self.album = self.add_album() + self.cover_path = os.path.join(self.album.path, b'mycover.jpg') def tearDown(self): self.unload_plugins() self.teardown_beets() + def check_cover_is_stored(self): + self.assertEqual(self.album['artpath'], self.cover_path) + with open(util.syspath(self.cover_path), 'r') as f: + self.assertEqual(f.read(), 'IMAGE') + def test_set_art_from_folder(self): self.touch(b'c\xc3\xb6ver.jpg', dir=self.album.path, content='IMAGE') self.run_command('fetchart') - cover_path = os.path.join(self.album.path, b'mycover.jpg') self.album.load() - self.assertEqual(self.album['artpath'], cover_path) - with open(util.syspath(cover_path), 'r') as f: - self.assertEqual(f.read(), 'IMAGE') + self.check_cover_is_stored() def test_filesystem_does_not_pick_up_folder(self): os.makedirs(os.path.join(self.album.path, b'mycover.jpg'))