test_fetchart: Avoid duplicate code in future tests.
@@ -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'))
