mirror of
https://github.com/beetbox/beets.git
synced 2025-12-22 00:23:33 +01:00
Raise configuration error if BEETSDIR is file
This commit is contained in:
parent
e916609eee
commit
165c28e967
2 changed files with 9 additions and 0 deletions
|
|
@ -793,6 +793,8 @@ class Configuration(RootView):
|
|||
if self._env_var in os.environ:
|
||||
appdir = os.environ[self._env_var]
|
||||
appdir = os.path.abspath(os.path.expanduser(appdir))
|
||||
if os.path.isfile(appdir):
|
||||
raise ConfigError('%s must be a directory' % self._env_var)
|
||||
|
||||
else:
|
||||
# Search platform-specific locations. If no config file is
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ from beets import importer
|
|||
from beets.mediafile import MediaFile
|
||||
from beets import config
|
||||
from beets import plugins
|
||||
from beets.util.confit import ConfigError
|
||||
|
||||
|
||||
class ListTest(_common.TestCase):
|
||||
|
|
@ -683,6 +684,12 @@ class ConfigTest(_common.TestCase):
|
|||
config.read()
|
||||
self.assertEqual(config['anoption'].get(), 'overwrite')
|
||||
|
||||
def test_beetsdir_points_to_file_error(self):
|
||||
beetsdir = os.path.join(self.temp_dir, 'beetsfile')
|
||||
open(beetsdir, 'a').close()
|
||||
os.environ['BEETSDIR'] = beetsdir
|
||||
self.assertRaises(ConfigError, ui._raw_main, 'test')
|
||||
|
||||
def test_beetsdir_config_does_not_load_default_user_config(self):
|
||||
os.environ['BEETSDIR'] = self.beetsdir
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue