mirror of
https://github.com/beetbox/beets.git
synced 2026-02-23 07:44:38 +01:00
pre-resolve package path for lazy-load configuration
`test_ui.ConfigTest.test_command_line_option_relative_to_working_dir` was failing because it changes working directories before the relative lazy-loaded default configuration path is resolved (`../beets/__init__.py`), later causing a `beets.util.confit.NotFoundError`. The Configuration object has been modified so that lazy-load configurations resolve the path in advance.
This commit is contained in:
parent
3ede5f26c8
commit
5213673616
1 changed files with 4 additions and 3 deletions
|
|
@ -794,6 +794,8 @@ class Configuration(RootView):
|
|||
super(Configuration, self).__init__([])
|
||||
self.appname = appname
|
||||
self.modname = modname
|
||||
# Pre-resolve default source location
|
||||
self._package_path = _package_path(appname)
|
||||
|
||||
self._env_var = '{0}DIR'.format(self.appname.upper())
|
||||
|
||||
|
|
@ -822,9 +824,8 @@ class Configuration(RootView):
|
|||
`modname` if it was given.
|
||||
"""
|
||||
if self.modname:
|
||||
pkg_path = _package_path(self.modname)
|
||||
if pkg_path:
|
||||
filename = os.path.join(pkg_path, DEFAULT_FILENAME)
|
||||
if self._package_path:
|
||||
filename = os.path.join(self._package_path, DEFAULT_FILENAME)
|
||||
if os.path.isfile(filename):
|
||||
self.add(ConfigSource(load_yaml(filename), filename, True))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue