@@ 69-117 (lines=49) @@ | ||
66 | self.assertEqual(indention_depth, (0, INDENT.IndentType.Initial, 0)) |
|
67 | ||
68 | ||
69 | class TestCalcLineIndentionDepthFromFoldMarker(TestCase): |
|
70 | """ |
|
71 | This test is to show the behaviour for an indention coming from a fold marker. |
|
72 | ||
73 | A fold marker is defined by ;; |
|
74 | and meant to be a synthatic sugar definition to fold multiple sections at once. |
|
75 | For example you can group all meters together or all about problem X. |
|
76 | """ |
|
77 | ||
78 | def test_with_empty_line(self): |
|
79 | """ |
|
80 | Due to the fold marker the indention depth is 1. |
|
81 | ||
82 | Thus the following indention depth stays at 1 |
|
83 | but the line itself is rendered as zero. |
|
84 | This prevents a lot of whitespaces in the file |
|
85 | if you split up your section. |
|
86 | """ |
|
87 | line = "" |
|
88 | indention_depth = indention_depth_from_fold(line) |
|
89 | self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) |
|
90 | ||
91 | def test_with_comment(self): |
|
92 | """Comment are printed in the same indention level as given.""" |
|
93 | line = "; This is a comment" |
|
94 | indention_depth = indention_depth_from_fold(line) |
|
95 | self.assertEqual(indention_depth, (1, INDENT.IndentType.FoldMarker, 1)) |
|
96 | ||
97 | def test_with_fold_marker(self): |
|
98 | """Additional fold marker will be printed at the same level as the previous fold marker.""" |
|
99 | line = ";; This is a fold marker" |
|
100 | indention_depth = indention_depth_from_fold(line) |
|
101 | self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) |
|
102 | ||
103 | def test_with_section(self): |
|
104 | """A section increases the depth context.""" |
|
105 | line = "[Section]" |
|
106 | indention_depth = indention_depth_from_fold(line) |
|
107 | self.assertEqual(indention_depth, (1, INDENT.IndentType.Section, 2)) |
|
108 | ||
109 | def test_with_key_value(self): |
|
110 | """ |
|
111 | Special handled case since it is invalid. |
|
112 | ||
113 | KeyValue pairs stay at level 1. |
|
114 | """ |
|
115 | line = "Key = Value" |
|
116 | indention_depth = indention_depth_from_fold(line) |
|
117 | self.assertEqual(indention_depth, (1, INDENT.IndentType.FoldMarker, 1)) |
|
118 | ||
119 | ||
120 | class TestCalcLineIndentionDepthFromSection(TestCase): |
|
@@ 26-66 (lines=41) @@ | ||
23 | return INDENT.calc_line_indention_depth(line, INDENT.IndentType.Section, 1) |
|
24 | ||
25 | ||
26 | class TestCalcLineIndentionDepthFromInitial(TestCase): |
|
27 | """ |
|
28 | This test is for showing the behaviour detecting different indenttypes. |
|
29 | ||
30 | Context depth can increase depending how the document starts. |
|
31 | It accepts invalid Rainmeter definitions like: |
|
32 | ||
33 | Key=Value |
|
34 | ||
35 | at the beginning of your document. This will not fail the indention itself. |
|
36 | """ |
|
37 | ||
38 | def test_with_empty_line(self): |
|
39 | """An empty line should be ignored.""" |
|
40 | line = "" |
|
41 | indention_depth = indention_depth_from_initial(line) |
|
42 | self.assertEqual(indention_depth, (0, INDENT.IndentType.Initial, 0)) |
|
43 | ||
44 | def test_with_comment(self): |
|
45 | """A comment will be ignored.""" |
|
46 | line = "; This is a comment" |
|
47 | indention_depth = indention_depth_from_initial(line) |
|
48 | self.assertEqual(indention_depth, (0, INDENT.IndentType.Initial, 0)) |
|
49 | ||
50 | def test_with_fold_marker(self): |
|
51 | """Fold markers increase the indention depth.""" |
|
52 | line = ";; This is a fold marker" |
|
53 | indention_depth = indention_depth_from_initial(line) |
|
54 | self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) |
|
55 | ||
56 | def test_with_section(self): |
|
57 | """Section increase the indention depth.""" |
|
58 | line = "[Section]" |
|
59 | indention_depth = indention_depth_from_initial(line) |
|
60 | self.assertEqual(indention_depth, (0, INDENT.IndentType.Section, 1)) |
|
61 | ||
62 | def test_with_key_value(self): |
|
63 | """Key values are actually invalid but they stay at the same indention level.""" |
|
64 | line = "Key = Value" |
|
65 | indention_depth = indention_depth_from_initial(line) |
|
66 | self.assertEqual(indention_depth, (0, INDENT.IndentType.Initial, 0)) |
|
67 | ||
68 | ||
69 | class TestCalcLineIndentionDepthFromFoldMarker(TestCase): |
|
@@ 120-151 (lines=32) @@ | ||
117 | self.assertEqual(indention_depth, (1, INDENT.IndentType.FoldMarker, 1)) |
|
118 | ||
119 | ||
120 | class TestCalcLineIndentionDepthFromSection(TestCase): |
|
121 | """Section increase the depth level.""" |
|
122 | ||
123 | def test_with_empty_line(self): |
|
124 | """Empty lines are ignored.""" |
|
125 | line = "" |
|
126 | indention_depth = indention_depth_from_section(line) |
|
127 | self.assertEqual(indention_depth, (0, INDENT.IndentType.Section, 1)) |
|
128 | ||
129 | def test_with_comment(self): |
|
130 | """Comment are printed on same level as key value pairs.""" |
|
131 | line = "; This is a comment" |
|
132 | indention_depth = indention_depth_from_section(line) |
|
133 | self.assertEqual(indention_depth, (1, INDENT.IndentType.Section, 1)) |
|
134 | ||
135 | def test_with_fold_marker(self): |
|
136 | """Invalid construct, but this counts as a simple comment.""" |
|
137 | line = ";; This is a fold marker" |
|
138 | indention_depth = indention_depth_from_section(line) |
|
139 | self.assertEqual(indention_depth, (0, INDENT.IndentType.FoldMarker, 1)) |
|
140 | ||
141 | def test_with_section(self): |
|
142 | """Invalid construct. Section following a section are staying on the same level.""" |
|
143 | line = "[Section]" |
|
144 | indention_depth = indention_depth_from_section(line) |
|
145 | self.assertEqual(indention_depth, (0, INDENT.IndentType.Section, 1)) |
|
146 | ||
147 | def test_with_key_value(self): |
|
148 | """KeyValue Pairs are printed on the next level.""" |
|
149 | line = "Key = Value" |
|
150 | indention_depth = indention_depth_from_section(line) |
|
151 | self.assertEqual(indention_depth, (1, INDENT.IndentType.Section, 1)) |
|
152 | ||
153 | ||
154 | class TestIndentWholeSection(TestCase): |