Skip to content

Commit

Permalink
Further tests for deserializing Python objects during inject_plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter committed Apr 5, 2024
1 parent 01219bd commit 7904925
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/unit/test_mkdocs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,21 @@ def test_round_trip(self):
self.assertEqual(self.out.getvalue(), expected)

def test_python_tag(self):
cfg = 'plugins:\n - foo:\n option: !!python/none'
cfg = ('plugins:\n'
' - foo:\n option: !!python/none\n' +
' - bar:\n option: !!python/name:io.StringIO')
with mock.patch('builtins.open',
mock_open_files({'mkdocs.yml': cfg})), \
mock.patch('mike.mkdocs_utils.NamedTemporaryFile',
return_value=self.out), \
mock.patch('os.remove') as mremove:
with mkdocs_utils.inject_plugin('mkdocs.yml') as f:
self.assertEqual(f, self.out.name)
newcfg = yaml.safe_load(self.out.getvalue())
newcfg = yaml.load(self.out.getvalue(), yaml.Loader)
mremove.assert_called_once()

self.assertEqual(newcfg, {'plugins': [
'mike', {'foo': {'option': None}},
'mike', {'foo': {'option': None}}, {'bar': {'option': StringIO}},
]})

def test_inherit(self):
Expand Down

0 comments on commit 7904925

Please sign in to comment.