| 1 |
|
| 2 |
e. |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
""" |
| 13 |
Test module for docutils/utils/math/__init__.py. |
| 14 |
""" |
| 15 |
|
| 16 |
from pathlib import Path |
| 17 |
import sys |
| 18 |
import unittest |
| 19 |
|
| 20 |
if __name__ == '__main__': |
| 21 |
|
| 22 |
|
| 23 |
sys.path.insert(0, str(Path(__file__).resolve().parents[3])) |
| 24 |
|
| 25 |
from docutils.utils import math |
| 26 |
|
| 27 |
TEST_ROOT = Path(__file__).parents[2] |
| 28 |
|
| 29 |
|
| 30 |
class MathTests(unittest.TestCase): |
| 31 |
|
| 32 |
tests = [('a + b = c', 'equation*'), |
| 33 |
(r'x = \begin{cases} -1&x<0 \\ 1&x>0 \end{cases}', 'equation*'), |
| 34 |
(r'a + 2b = c \\ 3a + b = 2c', 'align*'), |
| 35 |
] |
| 36 |
|
| 37 |
def test_pick_math_environment(self): |
| 38 |
for sample, result in self.tests: |
| 39 |
self.assertEqual(math.pick_math_environment(sample), result) |
| 40 |
|
| 41 |
def test_wrap_math_code(self): |
| 42 |
for sample, env in self.tests: |
| 43 |
self.assertEqual(math.wrap_math_code(sample, as_block=False), |
| 44 |
f'${sample}$') |
| 45 |
self.assertEqual(math.wrap_math_code(sample, as_block=True), |
| 46 |
f'\\begin{{{env}}}\n' |
| 47 |
f'{sample}\n' |
| 48 |
f'\\end{{{env}}}') |
| 49 |
|
| 50 |
|
| 51 |
if __name__ == '__main__': |
| 52 |
unittest.main() |