Completed
Push — master ( 7a3d73...0e531d )
by Christophe
59s
created

test_empty()   A

Complexity

Conditions 2

Size

Total Lines 74

Duplication

Lines 74
Ratio 100 %
Metric Value
cc 2
dl 74
loc 74
rs 9.0335

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
# This Python file uses the following encoding: utf-8
2
from unittest import TestCase
3
from pandocfilters import Div, Str, RawBlock
4
5
import json
6
7
import pandoc_latex_environment
8
9
def init():
10
    if hasattr(pandoc_latex_environment.getDefined, 'value'):
11
        delattr(pandoc_latex_environment.getDefined, 'value')
12
13 View Code Duplication
def test_div():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
14
    init()
15
16
    meta = {
17
        'latex-environment': {
18
            'c': {
19
                'test': {
20
                    'c': [
21
                        {
22
                            'c': [
23
                                {
24
                                    'c': 'class1',
25
                                    't': 'Str'
26
                                }
27
                            ],
28
                            't': 'MetaInlines'
29
                        },
30
                        {
31
                            'c': [
32
                                {
33
                                    'c': 'class2',
34
                                    't': 'Str'
35
                                }
36
                            ],
37
                            't': 'MetaInlines'
38
                        }
39
                    ],
40
                    't': 'MetaList'
41
                }
42
            },
43
            't': 'MetaMap'
44
        }
45
    }
46
47
    src = json.loads(json.dumps(Div(
48
        [
49
            '',
50
            [
51
                'class1',
52
                'class2'
53
            ],
54
            []
55
        ],
56
        [
57
            {
58
                'c': [
59
                    {
60
                        'c': 'content',
61
                        't': 'Str'
62
                    }
63
                ],
64
                't': 'Plain'
65
            }
66
        ]
67
    )))
68
    dest = json.loads(json.dumps(Div(
69
        [
70
            '',
71
            [
72
                'class1',
73
                'class2'
74
            ],
75
            []
76
        ],
77
        [
78
            {
79
                'c': [
80
                    'tex',
81
                    '\\begin{test}'
82
                ],
83
                't': 'RawBlock'
84
            },
85
            {
86
                'c': [
87
                    {
88
                        'c': 'content',
89
                        't': 'Str'
90
                    }
91
                ],
92
                't': 'Plain'
93
            },
94
            {
95
                'c': [
96
                    'tex',
97
                    '\\end{test}'
98
                ],
99
                't': 'RawBlock'
100
            }
101
        ]
102
    )))
103
104
    pandoc_latex_environment.environment(src['t'], src['c'], 'latex', meta)
105
106
    assert json.loads(json.dumps(src)) == dest
107
108 View Code Duplication
def test_empty():
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
109
    init()
110
111
    meta = {
112
        'latex-environment': {
113
            'c': {
114
                'test': {
115
                    'c': [
116
                        {
117
                            'c': [
118
                                {
119
                                    'c': 'class1',
120
                                    't': 'Str'
121
                                }
122
                            ],
123
                            't': 'MetaInlines'
124
                        },
125
                        {
126
                            'c': [
127
                                {
128
                                    'c': 'class2',
129
                                    't': 'Str'
130
                                }
131
                            ],
132
                            't': 'MetaInlines'
133
                        }
134
                    ],
135
                    't': 'MetaList'
136
                }
137
            },
138
            't': 'MetaMap'
139
        }
140
    }
141
142
    src = json.loads(json.dumps(Div(
143
        [
144
            '',
145
            [],
146
            []
147
        ],
148
        [
149
            {
150
                'c': [
151
                    {
152
                        'c': 'content',
153
                        't': 'Str'
154
                    }
155
                ],
156
                't': 'Plain'
157
            }
158
        ]
159
    )))
160
    dest = json.loads(json.dumps(Div(
161
        [
162
            '',
163
            [],
164
            []
165
        ],
166
        [
167
            {
168
                'c': [
169
                    {
170
                        'c': 'content',
171
                        't': 'Str'
172
                    }
173
                ],
174
                't': 'Plain'
175
            }
176
        ]
177
    )))
178
179
    pandoc_latex_environment.environment(src['t'], src['c'], 'latex', meta)
180
181
    assert json.loads(json.dumps(src)) == dest
182
183