Skip to content

Commit

Permalink
Add test_markup()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed May 11, 2024
1 parent 4d55b17 commit 385571d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions jcvi/graphics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ def markup(s: str):
"""
Change the string to latex format, and italicize the text between *.
"""
if not rcParams["text.usetex"]:
return s
if "$" in s:
return s
s = latex(s)
Expand Down
14 changes: 11 additions & 3 deletions tests/graphics/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import pytest

from jcvi.graphics.base import latex, markup, rc


@pytest.mark.parametrize(
"s,expected",
Expand All @@ -24,15 +26,21 @@ def test_shorten(s, expected):
@pytest.mark.parametrize(
"s,expected",
[
("grape_grape vs peach_peach", "grape\_grape vs peach\_peach"),
("grape_grape vs peach_peach", r"grape\_grape vs peach\_peach"),
],
)
def test_latex(s, expected):
from jcvi.graphics.base import latex

assert latex(s) == expected, "Expect {}".format(expected)


def test_markup():
rc("text", usetex=True)
s = "Prupe_1G289800.1"
assert markup(s) == r"Prupe\_1G289800.1"
rc("text", usetex=False)
assert markup(s) == s


@pytest.mark.parametrize(
"figname,format,expected",
[
Expand Down

0 comments on commit 385571d

Please sign in to comment.