Extended LaTeX tests on bad commands
This commit is contained in:
parent
b2cf86b905
commit
d8d9bf4dcd
@ -53,3 +53,61 @@ def test_latex():
|
|||||||
assert len(os.listdir(d.media.dir())) == 2
|
assert len(os.listdir(d.media.dir())) == 2
|
||||||
assert stripHTML(f.cards()[0].q()) == "[latex]foo[/latex]"
|
assert stripHTML(f.cards()[0].q()) == "[latex]foo[/latex]"
|
||||||
assert ".png" in oldcard.q()
|
assert ".png" in oldcard.q()
|
||||||
|
# turn it on again so other test don't suffer
|
||||||
|
anki.latex.build = True
|
||||||
|
|
||||||
|
def test_bad_latex_command_write18():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\write18")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_readline():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\readline")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_input():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\input")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_include():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\include")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_catcode():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\catcode")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_openout():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\openout")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_write():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\write")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_loop():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\loop")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_def():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\def")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_bad_latex_command_shipout():
|
||||||
|
(result, msg) = _test_includes_bad_command("\\shipout")
|
||||||
|
assert result, msg
|
||||||
|
|
||||||
|
def test_good_latex_command_works():
|
||||||
|
# inserting commands beginning with a bad name should not raise an error
|
||||||
|
(result, msg) = _test_includes_bad_command("\\defeq")
|
||||||
|
assert not result, msg
|
||||||
|
# normal commands should not either
|
||||||
|
(result, msg) = _test_includes_bad_command("\\emph")
|
||||||
|
assert not result, msg
|
||||||
|
|
||||||
|
def _test_includes_bad_command(bad):
|
||||||
|
d = getEmptyCol()
|
||||||
|
f = d.newNote()
|
||||||
|
f['Front'] = u'[latex]%s[/latex]' % bad;
|
||||||
|
d.addNote(f)
|
||||||
|
q = f.cards()[0].q()
|
||||||
|
return ("'%s' is not allowed on cards" % bad in q, "Card content: %s" % q)
|
Loading…
Reference in New Issue
Block a user