]> git.madduck.net Git - etc/vim.git/blob - tests/data/simple_cases/composition_no_trailing_comma.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

f17b89dea8d6a35a04f475390846ab2d1be692e6
[etc/vim.git] / tests / data / simple_cases / composition_no_trailing_comma.py
1 class C:
2     def test(self) -> None:
3         with patch("black.out", print):
4             self.assertEqual(
5                 unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
6             )
7             self.assertEqual(
8                 unstyle(str(report)),
9                 "1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
10             )
11             self.assertEqual(
12                 unstyle(str(report)),
13                 "2 files reformatted, 1 file left unchanged, 1 file failed to"
14                 " reformat.",
15             )
16             self.assertEqual(
17                 unstyle(str(report)),
18                 "2 files reformatted, 2 files left unchanged, 2 files failed to"
19                 " reformat.",
20             )
21             for i in (a,):
22                 if (
23                     # Rule 1
24                     i % 2 == 0
25                     # Rule 2
26                     and i % 3 == 0
27                 ):
28                     while (
29                         # Just a comment
30                         call()
31                         # Another
32                     ):
33                         print(i)
34         xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
35             push_manager=context.request.resource_manager,
36             max_items_to_push=num_items,
37             batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE
38         ).push(
39             # Only send the first n items.
40             items=items[:num_items]
41         )
42         return (
43             'Utterly failed doctest test for %s\n   File "%s", line %s, in %s\n\n%s'
44             % (test.name, test.filename, lineno, lname, err)
45         )
46
47     def omitting_trailers(self) -> None:
48         get_collection(
49             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
50         )[OneLevelIndex]
51         get_collection(
52             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
53         )[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
54         d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
55             22
56         ]
57         assignment = (
58             some.rather.elaborate.rule() and another.rule.ending_with.index[123]
59         )
60
61     def easy_asserts(self) -> None:
62         assert {
63             key1: value1,
64             key2: value2,
65             key3: value3,
66             key4: value4,
67             key5: value5,
68             key6: value6,
69             key7: value7,
70             key8: value8,
71             key9: value9
72         } == expected, "Not what we expected"
73
74         assert expected == {
75             key1: value1,
76             key2: value2,
77             key3: value3,
78             key4: value4,
79             key5: value5,
80             key6: value6,
81             key7: value7,
82             key8: value8,
83             key9: value9
84         }, "Not what we expected"
85
86         assert expected == {
87             key1: value1,
88             key2: value2,
89             key3: value3,
90             key4: value4,
91             key5: value5,
92             key6: value6,
93             key7: value7,
94             key8: value8,
95             key9: value9
96         }
97
98     def tricky_asserts(self) -> None:
99         assert {
100             key1: value1,
101             key2: value2,
102             key3: value3,
103             key4: value4,
104             key5: value5,
105             key6: value6,
106             key7: value7,
107             key8: value8,
108             key9: value9
109         } == expected(
110             value, is_going_to_be="too long to fit in a single line", srsly=True
111         ), "Not what we expected"
112
113         assert {
114             key1: value1,
115             key2: value2,
116             key3: value3,
117             key4: value4,
118             key5: value5,
119             key6: value6,
120             key7: value7,
121             key8: value8,
122             key9: value9
123         } == expected, (
124             "Not what we expected and the message is too long to fit in one line"
125         )
126
127         assert expected(
128             value, is_going_to_be="too long to fit in a single line", srsly=True
129         ) == {
130             key1: value1,
131             key2: value2,
132             key3: value3,
133             key4: value4,
134             key5: value5,
135             key6: value6,
136             key7: value7,
137             key8: value8,
138             key9: value9
139         }, "Not what we expected"
140
141         assert expected == {
142             key1: value1,
143             key2: value2,
144             key3: value3,
145             key4: value4,
146             key5: value5,
147             key6: value6,
148             key7: value7,
149             key8: value8,
150             key9: value9
151         }, (
152             "Not what we expected and the message is too long to fit in one line"
153             " because it's too long"
154         )
155
156         dis_c_instance_method = """\
157         %3d           0 LOAD_FAST                1 (x)
158                       2 LOAD_CONST               1 (1)
159                       4 COMPARE_OP               2 (==)
160                       6 LOAD_FAST                0 (self)
161                       8 STORE_ATTR               0 (x)
162                      10 LOAD_CONST               0 (None)
163                      12 RETURN_VALUE
164         """ % (
165             _C.__init__.__code__.co_firstlineno + 1,
166         )
167
168         assert (
169             expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
170             == {
171                 key1: value1,
172                 key2: value2,
173                 key3: value3,
174                 key4: value4,
175                 key5: value5,
176                 key6: value6,
177                 key7: value7,
178                 key8: value8,
179                 key9: value9
180             }
181         )
182
183
184
185 # output
186
187 class C:
188     def test(self) -> None:
189         with patch("black.out", print):
190             self.assertEqual(
191                 unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
192             )
193             self.assertEqual(
194                 unstyle(str(report)),
195                 "1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
196             )
197             self.assertEqual(
198                 unstyle(str(report)),
199                 "2 files reformatted, 1 file left unchanged, 1 file failed to"
200                 " reformat.",
201             )
202             self.assertEqual(
203                 unstyle(str(report)),
204                 "2 files reformatted, 2 files left unchanged, 2 files failed to"
205                 " reformat.",
206             )
207             for i in (a,):
208                 if (
209                     # Rule 1
210                     i % 2 == 0
211                     # Rule 2
212                     and i % 3 == 0
213                 ):
214                     while (
215                         # Just a comment
216                         call()
217                         # Another
218                     ):
219                         print(i)
220         xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
221             push_manager=context.request.resource_manager,
222             max_items_to_push=num_items,
223             batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
224         ).push(
225             # Only send the first n items.
226             items=items[:num_items]
227         )
228         return (
229             'Utterly failed doctest test for %s\n   File "%s", line %s, in %s\n\n%s'
230             % (test.name, test.filename, lineno, lname, err)
231         )
232
233     def omitting_trailers(self) -> None:
234         get_collection(
235             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
236         )[OneLevelIndex]
237         get_collection(
238             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
239         )[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
240         d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
241             22
242         ]
243         assignment = (
244             some.rather.elaborate.rule() and another.rule.ending_with.index[123]
245         )
246
247     def easy_asserts(self) -> None:
248         assert {
249             key1: value1,
250             key2: value2,
251             key3: value3,
252             key4: value4,
253             key5: value5,
254             key6: value6,
255             key7: value7,
256             key8: value8,
257             key9: value9,
258         } == expected, "Not what we expected"
259
260         assert expected == {
261             key1: value1,
262             key2: value2,
263             key3: value3,
264             key4: value4,
265             key5: value5,
266             key6: value6,
267             key7: value7,
268             key8: value8,
269             key9: value9,
270         }, "Not what we expected"
271
272         assert expected == {
273             key1: value1,
274             key2: value2,
275             key3: value3,
276             key4: value4,
277             key5: value5,
278             key6: value6,
279             key7: value7,
280             key8: value8,
281             key9: value9,
282         }
283
284     def tricky_asserts(self) -> None:
285         assert {
286             key1: value1,
287             key2: value2,
288             key3: value3,
289             key4: value4,
290             key5: value5,
291             key6: value6,
292             key7: value7,
293             key8: value8,
294             key9: value9,
295         } == expected(
296             value, is_going_to_be="too long to fit in a single line", srsly=True
297         ), "Not what we expected"
298
299         assert {
300             key1: value1,
301             key2: value2,
302             key3: value3,
303             key4: value4,
304             key5: value5,
305             key6: value6,
306             key7: value7,
307             key8: value8,
308             key9: value9,
309         } == expected, (
310             "Not what we expected and the message is too long to fit in one line"
311         )
312
313         assert expected(
314             value, is_going_to_be="too long to fit in a single line", srsly=True
315         ) == {
316             key1: value1,
317             key2: value2,
318             key3: value3,
319             key4: value4,
320             key5: value5,
321             key6: value6,
322             key7: value7,
323             key8: value8,
324             key9: value9,
325         }, "Not what we expected"
326
327         assert expected == {
328             key1: value1,
329             key2: value2,
330             key3: value3,
331             key4: value4,
332             key5: value5,
333             key6: value6,
334             key7: value7,
335             key8: value8,
336             key9: value9,
337         }, (
338             "Not what we expected and the message is too long to fit in one line"
339             " because it's too long"
340         )
341
342         dis_c_instance_method = """\
343         %3d           0 LOAD_FAST                1 (x)
344                       2 LOAD_CONST               1 (1)
345                       4 COMPARE_OP               2 (==)
346                       6 LOAD_FAST                0 (self)
347                       8 STORE_ATTR               0 (x)
348                      10 LOAD_CONST               0 (None)
349                      12 RETURN_VALUE
350         """ % (
351             _C.__init__.__code__.co_firstlineno + 1,
352         )
353
354         assert (
355             expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
356             == {
357                 key1: value1,
358                 key2: value2,
359                 key3: value3,
360                 key4: value4,
361                 key5: value5,
362                 key6: value6,
363                 key7: value7,
364                 key8: value8,
365                 key9: value9,
366             }
367         )