File: test_clean_up_path.py

package info (click to toggle)
inkscape 1.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 402,900 kB
  • sloc: cpp: 547,256; python: 72,677; ansic: 63,355; javascript: 3,864; xml: 2,345; sh: 1,667; makefile: 824; perl: 614
file content (200 lines) | stat: -rw-r--r-- 4,940 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# -*- coding: utf-8 -*-
from clean_up_path import CleanUpPath
from inkex.tester import ComparisonMixin, TestCase
from inkex.tester.filters import CompareNumericFuzzy, CompareWithPathSpace
from inkex.tester.mock import Capture


class RemoveTrueDuplicatesTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [("--id=path_w_duplicates",)]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class RemoveClose2DuplicatesTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_line",
            "--minUse=True",
            "--minlength=0.1",
            "--minUseSub=True",
            "--minlengthSub=0.1",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class SimpleJoinLoopTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_simple_loop",
            "--joinEndSub=True",
            "--maxdistJoin=4",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class TwoCirclesDefaultTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [("--id=two_circles",)]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class SelfIntersectTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=self_intersect",
            "--joinEndSub=True",
            "--maxdistJoin=4",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class LoopCloseTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_oo",
            "--closeSub=True",
            "--maxdistClose=1",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class MixDuplicateTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_zmo",
            "--minUse=True",
            "--minlength=1",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class JoinRowTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_loops_and_row",
            "--closeSub=True",
            "--maxdistJoin=4",
            "--joinEndSub=True",
            "--maxdistClose=4",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class JoinRowNoReverseTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_loops_and_row",
            "--closeSub=True",
            "--maxdistClose=4",
            "--joinEndSub=True",
            "--maxdistJoin=4",
            "--allow_reverse=False",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class MixTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_mix",
            "--minUse=True",
            "--minlength=2",
            "--closeSub=True",
            "--maxdistClose=4",
            "--joinEndSub=True",
            "--maxdistJoin=4",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class MixStraightTest(ComparisonMixin, TestCase):
    effect_class = CleanUpPath
    comparisons = [
        (
            "--id=path_mix",
            "--joinEndSub=True",
            "--maxdistJoin=4",
            "--option_join=2",
        )
    ]
    compare_filters = [
        CompareWithPathSpace(),
        CompareNumericFuzzy(),
    ]
    compare_file = "svg/clean_up_path.svg"


class RaiseErrorsTest(TestCase):
    """Test errormsg on selecting not accepted elements."""

    def test_effect(self):
        """Test that error is presented when inkscape:path-effect selected."""
        args = [
            self.data_file("svg", "clean_up_path.svg"),
            "--id=ink_effect",
        ]
        ext = CleanUpPath()

        with Capture("stderr") as stderr:
            ext.run(args)
            self.assertIn(
                "inkscape:path-effect applied",
                stderr.getvalue(),
            )