Index: tests/test_page_outputs.py |
=================================================================== |
--- a/tests/test_page_outputs.py |
+++ b/tests/test_page_outputs.py |
@@ -1,8 +1,9 @@ |
+import logging |
import os |
import sys |
import runpy |
import mock |
import pytest |
from .conftest import ROOTPATH |
@@ -60,16 +61,30 @@ |
assert expected_output == output_pages_relative[filename] |
def test_cache(output_pages): |
source = FileSource(os.path.join('test_site')) |
assert source.get_cache_dir() == os.path.join('test_site', 'cache') |
+def test_broken_link_warnings(temp_site, tmpdir_factory, caplog): |
+ caplog.set_level(logging.WARNING) |
+ generate_static_pages(temp_site, tmpdir_factory) |
+ messages = {t[2] for t in caplog.record_tuples} |
+ expected_messages = [ |
+ 'Link from "brokenlink" to "missing" cannot be resolved', |
+ 'Link from "brokenlink-html" to "missing" cannot be resolved', |
+ 'Link from "brokenlink-tmpl" to "missing" cannot be resolved', |
+ ] |
+ for message in expected_messages: |
+ assert message in messages |
+ raise messages |
+ |
+ |
@pytest.mark.parametrize('filename,expected_output', dynamic_expected_outputs) |
def test_dynamic_server_handler(filename, expected_output, temp_site): |
def cleanup(page): |
return page.replace(os.linesep, '').strip() |
handler = DynamicServerHandler('localhost', 5000, str(temp_site)) |
environ = {'PATH_INFO': filename} |