1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
"""
Testing the project
(C) Laurent Franceschetti 2024
"""
import pytest
import test
from test.fixture import MacrosDocProject
def test_pages():
PROJECT = MacrosDocProject()
build_result = PROJECT.build(strict=False)
# did not fail
return_code = PROJECT.build_result.returncode
assert not return_code, "Failed when it should not"
# ----------------
# First page
# ----------------
page = PROJECT.get_page('index')
print("Has error:", page.has_error)
assert not page.has_error()
ERROR_MSG = f"Is rendered!:\n{page.markdown}\n---SOURCE:\n{page.source.markdown}\n---"
assert not page.is_markdown_rendered(), ERROR_MSG
# ----------------
# Second page
# ----------------
# there is intentionally an error (`foo` does not exist)
page = PROJECT.get_page('second')
assert not page.is_markdown_rendered()
def test_strict():
"This project must fail"
PROJECT = MacrosDocProject()
# it must not fail with the --strict option,
PROJECT.build(strict=True)
assert not PROJECT.build_result.returncode, "Failed when it should not"
|