diff --git a/beetsplug/importfeeds.py b/beetsplug/importfeeds.py index 893c3e99c..cf367fb5b 100644 --- a/beetsplug/importfeeds.py +++ b/beetsplug/importfeeds.py @@ -101,9 +101,13 @@ def _record_items(lib, basename, items): if config['importfeeds']['absolute_path']: paths.append(item.path) else: - paths.append(os.path.relpath( - item.path, relative_to - )) + try: + relpath = os.path.relpath(item.path, relative_to) + except ValueError: + # On Windows, it is sometimes not possible to construct a + # relative path (if the files are on different disks). + relpath = item.path + paths.append(relpath) if 'm3u' in formats: basename = bytestring_path( diff --git a/setup.cfg b/setup.cfg index 45387f883..870a7c1fb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,4 +9,4 @@ ignore=E241,E221 # List of files that have not been cleand up yet. We will try to reduce # this with each commit -exclude=test/test_config_command.py,test/test_files.py,test/test_art.py,test/test_dbcore.py,test/test_web.py,test/test_zero.py,test/rsrc/beetsplug/test.py,test/test_template.py,test/test_importfeeds.py,test/test_echonest.py,test/test_datequery.py,test/test_mb.py,test/test_convert.py,test/testall.py,test/test_player.py,test/test_query.py,test/test_mediafile.py,test/test_keyfinder.py,test/test_the.py,test/test_library.py,test/test_lyrics.py,test/test_ihate.py,test/test_vfs.py,test/test_replaygain.py,test/__init__.py,test/_common.py,test/test_mediafile_edge.py,test/test_ui.py +exclude=test/test_config_command.py,test/test_files.py,test/test_art.py,test/test_dbcore.py,test/test_web.py,test/test_zero.py,test/rsrc/beetsplug/test.py,test/test_template.py,test/test_echonest.py,test/test_datequery.py,test/test_mb.py,test/test_convert.py,test/testall.py,test/test_player.py,test/test_query.py,test/test_mediafile.py,test/test_keyfinder.py,test/test_the.py,test/test_library.py,test/test_lyrics.py,test/test_ihate.py,test/test_vfs.py,test/test_replaygain.py,test/__init__.py,test/_common.py,test/test_mediafile_edge.py,test/test_ui.py diff --git a/test/test_importfeeds.py b/test/test_importfeeds.py index 5fce7c09d..477cc3f2f 100644 --- a/test/test_importfeeds.py +++ b/test/test_importfeeds.py @@ -16,14 +16,15 @@ class ImportfeedsTestTest(unittest.TestCase): self.lib = Library(':memory:') self.feeds_dir = tempfile.mkdtemp() config['importfeeds']['dir'] = self.feeds_dir - + def tearDown(self): shutil.rmtree(self.feeds_dir) def test_multi_format_album_playlist(self): config['importfeeds']['formats'] = 'm3u_multi' album = Album(album='album/name', id=1) - item = Item(title='song', album_id=1, path='/path/to/item') + item_path = os.path.join('path', 'to', 'item') + item = Item(title='song', album_id=1, path=item_path) self.lib.add(album) self.lib.add(item) @@ -32,7 +33,7 @@ class ImportfeedsTestTest(unittest.TestCase): os.listdir(self.feeds_dir)[0]) self.assertTrue(playlist_path.endswith('album_name.m3u')) with open(playlist_path) as playlist: - self.assertIn('/path/to/item', playlist.read()) + self.assertIn(item_path, playlist.read()) def suite():