]> 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:

Cache generated comments
[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, "
14                 "1 file failed to reformat.",
15             )
16             self.assertEqual(
17                 unstyle(str(report)),
18                 "2 files reformatted, 2 files left unchanged, "
19                 "2 files failed to 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"
44             '  File "%s", line %s, in %s\n\n%s'
45             % (test.name, test.filename, lineno, lname, err)
46         )
47
48     def omitting_trailers(self) -> None:
49         get_collection(
50             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
51         )[OneLevelIndex]
52         get_collection(
53             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
54         )[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
55         d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
56             22
57         ]
58         assignment = (
59             some.rather.elaborate.rule() and another.rule.ending_with.index[123]
60         )
61
62     def easy_asserts(self) -> None:
63         assert {
64             key1: value1,
65             key2: value2,
66             key3: value3,
67             key4: value4,
68             key5: value5,
69             key6: value6,
70             key7: value7,
71             key8: value8,
72             key9: value9,
73         } == expected, "Not what we expected"
74
75         assert expected == {
76             key1: value1,
77             key2: value2,
78             key3: value3,
79             key4: value4,
80             key5: value5,
81             key6: value6,
82             key7: value7,
83             key8: value8,
84             key9: value9,
85         }, "Not what we expected"
86
87         assert expected == {
88             key1: value1,
89             key2: value2,
90             key3: value3,
91             key4: value4,
92             key5: value5,
93             key6: value6,
94             key7: value7,
95             key8: value8,
96             key9: value9,
97         }
98
99     def tricky_asserts(self) -> None:
100         assert {
101             key1: value1,
102             key2: value2,
103             key3: value3,
104             key4: value4,
105             key5: value5,
106             key6: value6,
107             key7: value7,
108             key8: value8,
109             key9: value9,
110         } == expected(
111             value, is_going_to_be="too long to fit in a single line", srsly=True
112         ), "Not what we expected"
113
114         assert {
115             key1: value1,
116             key2: value2,
117             key3: value3,
118             key4: value4,
119             key5: value5,
120             key6: value6,
121             key7: value7,
122             key8: value8,
123             key9: value9,
124         } == expected, (
125             "Not what we expected and the message is too long to fit in one line"
126         )
127
128         assert expected(
129             value, is_going_to_be="too long to fit in a single line", srsly=True
130         ) == {
131             key1: value1,
132             key2: value2,
133             key3: value3,
134             key4: value4,
135             key5: value5,
136             key6: value6,
137             key7: value7,
138             key8: value8,
139             key9: value9,
140         }, "Not what we expected"
141
142         assert expected == {
143             key1: value1,
144             key2: value2,
145             key3: value3,
146             key4: value4,
147             key5: value5,
148             key6: value6,
149             key7: value7,
150             key8: value8,
151             key9: value9,
152         }, (
153             "Not what we expected and the message is too long to fit "
154             "in one line because it's too long"
155         )
156
157         dis_c_instance_method = """\
158         %3d           0 LOAD_FAST                1 (x)
159                       2 LOAD_CONST               1 (1)
160                       4 COMPARE_OP               2 (==)
161                       6 LOAD_FAST                0 (self)
162                       8 STORE_ATTR               0 (x)
163                      10 LOAD_CONST               0 (None)
164                      12 RETURN_VALUE
165         """ % (
166             _C.__init__.__code__.co_firstlineno + 1,
167         )
168
169         assert (
170             expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
171             == {
172                 key1: value1,
173                 key2: value2,
174                 key3: value3,
175                 key4: value4,
176                 key5: value5,
177                 key6: value6,
178                 key7: value7,
179                 key8: value8,
180                 key9: value9,
181             }
182         )