From 22208a9471b37a75af113fdede8d9bdb13608f4c Mon Sep 17 00:00:00 2001 From: derwinlu Date: Mon, 23 Jan 2017 23:54:38 +0100 Subject: [PATCH] Add test checking url replcmnt of unkn. file There was no test case checking the behaviour of what happens when trying to {filename} an unknown file. Also changed the braces to `'` chars that we use elseware. --- pelican/contents.py | 2 +- pelican/tests/test_contents.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pelican/contents.py b/pelican/contents.py index 1ded6cdb..0e842b39 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -246,7 +246,7 @@ class Content(object): origin = origin.replace('\\', '/') # for Windows paths. else: logger.warning( - "Unable to find `%s`, skipping url replacement.", + "Unable to find '%s', skipping url replacement.", value.geturl(), extra={ 'limit_msg': ("Other resources were not found " "and their urls not replaced")}) diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index 2f774a6e..29a219f5 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -731,3 +731,19 @@ class TestStatic(LoggedTestCase): msg="Replacement Indicator 'unknown' not recognized, " "skipping replacement", level=logging.WARNING) + + def test_link_to_unknown_file(self): + "{filename} link to unknown file should trigger warning." + + html = 'link' + page = Page(content=html, + metadata={'title': 'fakepage'}, settings=self.settings, + source_path=os.path.join('dir', 'otherdir', 'fakepage.md'), + context=self.context) + content = page.get_content('') + + self.assertEqual(content, html) + self.assertLogCountEqual( + count=1, + msg="Unable to find 'foo', skipping url replacement.", + level=logging.WARNING)