-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve error message if using RenderLaTeX without jinja2 installed.
- Loading branch information
1 parent
6892c26
commit b42e360
Showing
5 changed files
with
46 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sys | ||
|
||
import pytest | ||
|
||
|
||
# this function works when used solely, | ||
# but not with other modules tests. | ||
@pytest.mark.skip(reason="can only test this separately from other modules") | ||
def test_missing_jinja2(): | ||
# we check that a proper and clear exception is raised | ||
# if jinja2 is missing when using RenderLaTeX | ||
# from https://stackoverflow.com/a/1350574/952234 | ||
import jinja2 | ||
# doesn't help. | ||
# jinja2_tmp = jinja2 | ||
sys.modules["jinja2"] = None | ||
from lena.output import RenderLaTeX | ||
with pytest.raises(ImportError) as err: | ||
r = RenderLaTeX("hello") | ||
assert str(err.value) == "RenderLaTeX can't be used because jinja2 is not found" | ||
# seems tests are run non-atomically, so need to return this | ||
# del sys.modules["jinja2"] | ||
# doesn't work: | ||
# sys.modules["jinja2"] = jinja2_tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters