test_tables   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 66
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A TableTest.conversion() 0 6 1
A TableTest.test_table() 0 48 2
1
from unittest import TestCase
2
3
from panflute import convert_text
4
from panflute.tools import PandocVersion
5
import pandoc_glfm
6
7
version = PandocVersion().version
8
9
10
class TableTest(TestCase):
11
    @classmethod
12
    def conversion(cls, markdown, fmt="markdown"):
13
        doc = convert_text(markdown, standalone=True)
14
        doc.format = fmt
15
        pandoc_glfm.main(doc)
16
        return doc
17
18
    def test_table(self):
19
        doc = TableTest.conversion(
20
            """
21
| Name | Details |
22
| ---  | ---     |
23
| Item1 | This text is on one line |
24
|       | This item has:<br><br>- Multiple items<br>- That we want listed separately |
25
            """,
26
        )
27
        text = convert_text(
28
            doc,
29
            input_format="panflute",
30
            output_format="markdown",
31
        )
32
33
        if version < (3, 6, 4):
34
            self.assertEqual(
35
                text,
36
                """
37
+-----------------------------------+-----------------------------------+
38
| Name                              | Details                           |
39
+===================================+===================================+
40
| Item1                             | This text is on one line          |
41
+-----------------------------------+-----------------------------------+
42
|                                   | This item has:                    |
43
|                                   |                                   |
44
|                                   | -   Multiple items                |
45
|                                   | -   That we want listed           |
46
|                                   |     separately                    |
47
+-----------------------------------+-----------------------------------+
48
                  """.strip()
49
            )
50
51
        else:
52
            self.assertEqual(
53
                text,
54
                """
55
+-----------------------------------+-----------------------------------+
56
| Name                              | Details                           |
57
+===================================+===================================+
58
| Item1                             | This text is on one line          |
59
+-----------------------------------+-----------------------------------+
60
|                                   | This item has:                    |
61
|                                   |                                   |
62
|                                   | - Multiple items                  |
63
|                                   | - That we want listed separately  |
64
+-----------------------------------+-----------------------------------+
65
                  """.strip()
66
            )
67