feat: parse questions von @dl9mj
This commit is contained in:
+9
-4
@@ -1,12 +1,17 @@
|
||||
import mistletoe
|
||||
from mistletoe import Document
|
||||
|
||||
from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
||||
|
||||
|
||||
def question_stub(input):
|
||||
return f"<question>{input}</question>" # TODO implement this stub
|
||||
|
||||
|
||||
def test_html(capsys):
|
||||
with capsys.disabled():
|
||||
with open("test/acceptanceTest.md") as file:
|
||||
content = file.read()
|
||||
output = mistletoe.markdown(content, FiftyOhmHtmlRenderer)
|
||||
with open("test/acceptanceTest.html", "w") as output_file:
|
||||
output_file.write(output)
|
||||
with FiftyOhmHtmlRenderer(question_stub) as renderer:
|
||||
output = renderer.render(Document(content))
|
||||
with open("test/acceptanceTest.html", "w") as output_file:
|
||||
output_file.write(output)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import pytest
|
||||
from mistletoe import Document
|
||||
|
||||
from renderer.fifty_ohm_html_renderer import FiftyOhmHtmlRenderer
|
||||
from renderer.fifty_ohm_latex_renderer import FiftyOhmLaTeXRenderer
|
||||
from test.util import paragraph
|
||||
|
||||
|
||||
@pytest.mark.html
|
||||
def test_comment_html():
|
||||
assertions = {
|
||||
"[question:123]": "123\n",
|
||||
"\n[question:123]\n": "123\n",
|
||||
"\n[question:123]\n[question:123]": "123\n123\n",
|
||||
"Foo\n[question:123]\nBar": paragraph("Foo") + "123\n" + paragraph("Bar"),
|
||||
}
|
||||
|
||||
def test_function(input):
|
||||
return f"{input}"
|
||||
|
||||
with FiftyOhmHtmlRenderer(test_function) as renderer:
|
||||
for assertion in assertions:
|
||||
assert renderer.render(Document(assertion)) == assertions[assertion]
|
||||
|
||||
|
||||
@pytest.mark.latex
|
||||
def test_comment_latex():
|
||||
assertions = {
|
||||
"[question:123]": "123",
|
||||
"\n[question:123]\n": "123",
|
||||
"\n[question:123]\n[question:123]": "123123",
|
||||
"Foo\n[question:123]\nBar": "\nFoo\n123\nBar\n",
|
||||
}
|
||||
|
||||
def test_function(input):
|
||||
return f"{input}"
|
||||
|
||||
with FiftyOhmLaTeXRenderer(test_function) as renderer:
|
||||
for assertion in assertions:
|
||||
assert renderer.render(Document(assertion)) == assertions[assertion]
|
||||
Reference in New Issue
Block a user