]> git.madduck.net Git - etc/vim.git/blob - tests/data/composition.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:

Add Black compatible configurations in documentation (#1366 & #1205) (#1371)
[etc/vim.git] / tests / data / composition.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         )