mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-27 09:58:31 +07:00
Merge pull request #3700 from theacodes/fix-3699
Fix crash when mkdocs_theme.yml is empty
This commit is contained in:
@@ -104,3 +104,22 @@ class ThemeTests(unittest.TestCase):
|
||||
],
|
||||
)
|
||||
self.assertEqual(theme.static_templates, {'sitemap.xml', 'child.html', 'parent.html'})
|
||||
|
||||
def test_empty_config_file(self):
|
||||
# Test for themes with *empty* mkdocs_theme.yml.
|
||||
# See https://github.com/mkdocs/mkdocs/issues/3699
|
||||
m = mock.Mock(
|
||||
# yaml.load returns "None" for an empty file
|
||||
side_effect=[None]
|
||||
)
|
||||
with mock.patch('yaml.load', m) as m:
|
||||
theme = Theme(name='mkdocs')
|
||||
# Should only have the default name and locale __vars set in
|
||||
# Theme.__init__()
|
||||
self.assertEqual(
|
||||
dict(theme),
|
||||
{
|
||||
'name': 'mkdocs',
|
||||
'locale': parse_locale('en'),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -138,6 +138,9 @@ class Theme(MutableMapping[str, Any]):
|
||||
f"Please upgrade to a current version of the theme."
|
||||
)
|
||||
|
||||
if theme_config is None:
|
||||
theme_config = {}
|
||||
|
||||
log.debug(f"Loaded theme configuration for '{name}' from '{file_path}': {theme_config}")
|
||||
|
||||
if parent_theme := theme_config.pop('extends', None):
|
||||
|
||||
Reference in New Issue
Block a user