1
0
Fork 0
forked from github/pelican

Log warnings about files that would have been processed by disabled readers

This commit is contained in:
boxydog 2024-06-17 08:11:21 -05:00
commit f19de98b9e
7 changed files with 119 additions and 13 deletions

View file

@ -9,10 +9,11 @@ import unittest
from collections.abc import Sequence
from shutil import rmtree
from tempfile import TemporaryDirectory, mkdtemp
from unittest.mock import patch
from unittest.mock import PropertyMock, patch
from rich.console import Console
import pelican.readers
from pelican import Pelican, __version__, main
from pelican.generators import StaticGenerator
from pelican.settings import read_settings
@ -303,3 +304,24 @@ class TestPelican(LoggedTestCase):
main(["-o", temp_dir, "pelican/tests/simple_content"])
self.assertIn("Processed 1 article", out.getvalue())
self.assertEqual("", err.getvalue())
def test_main_on_content_markdown_disabled(self):
"""Invoke main on simple_content directory."""
with patch.object(
pelican.readers.MarkdownReader, "enabled", new_callable=PropertyMock
) as attr_mock:
attr_mock.return_value = False
out, err = io.StringIO(), io.StringIO()
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
with TemporaryDirectory() as temp_dir:
# Don't highlight anything.
# See https://rich.readthedocs.io/en/stable/highlighting.html
with patch("pelican.console", new=Console(highlight=False)):
main(["-o", temp_dir, "pelican/tests/simple_content"])
self.assertIn("Processed 0 articles", out.getvalue())
self.assertLogCountEqual(
1,
".*article_with_md_extension.md: "
"Could not import markdown.Markdown. "
"Have you installed the markdown package?",
)