]> git.madduck.net Git - etc/vim.git/blob - tests/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 instructions for running Black on save in Vim (#255)
[etc/vim.git] / tests / composition.py
1 class C:
2
3     def test(self) -> None:
4         with patch("black.out", print):
5             self.assertEqual(
6                 unstyle(str(report)), "1 file reformatted, 1 file failed to reformat."
7             )
8             self.assertEqual(
9                 unstyle(str(report)),
10                 "1 file reformatted, 1 file left unchanged, 1 file failed to reformat.",
11             )
12             self.assertEqual(
13                 unstyle(str(report)),
14                 "2 files reformatted, 1 file left unchanged, "
15                 "1 file failed to reformat.",
16             )
17             self.assertEqual(
18                 unstyle(str(report)),
19                 "2 files reformatted, 2 files left unchanged, "
20                 "2 files failed to reformat.",
21             )
22             for i in (a,):
23                 if (
24                     # Rule 1
25                     i % 2 == 0
26                     # Rule 2
27                     and i % 3 == 0
28                 ):
29                     while (
30                         # Just a comment
31                         call()
32                         # Another
33                     ):
34                         print(i)
35         xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
36             push_manager=context.request.resource_manager,
37             max_items_to_push=num_items,
38             batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
39         ).push(
40             # Only send the first n items.
41             items=items[:num_items]
42         )
43         return (
44             "Utterly failed doctest test for %s\n"
45             '  File "%s", line %s, in %s\n\n%s'
46             % (test.name, test.filename, lineno, lname, err)
47         )
48
49     def omitting_trailers(self) -> None:
50         get_collection(
51             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
52         )[OneLevelIndex]
53         get_collection(
54             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
55         )[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
56         d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
57             22
58         ]
59         assignment = (
60             some.rather.elaborate.rule() and another.rule.ending_with.index[123]
61         )
62
63     def easy_asserts(self) -> None:
64         assert {
65             key1: value1,
66             key2: value2,
67             key3: value3,
68             key4: value4,
69             key5: value5,
70             key6: value6,
71             key7: value7,
72             key8: value8,
73             key9: value9,
74         } == expected, "Not what we expected"
75
76         assert expected == {
77             key1: value1,
78             key2: value2,
79             key3: value3,
80             key4: value4,
81             key5: value5,
82             key6: value6,
83             key7: value7,
84             key8: value8,
85             key9: value9,
86         }, "Not what we expected"
87
88         assert expected == {
89             key1: value1,
90             key2: value2,
91             key3: value3,
92             key4: value4,
93             key5: value5,
94             key6: value6,
95             key7: value7,
96             key8: value8,
97             key9: value9,
98         }
99
100     def tricky_asserts(self) -> None:
101         assert {
102             key1: value1,
103             key2: value2,
104             key3: value3,
105             key4: value4,
106             key5: value5,
107             key6: value6,
108             key7: value7,
109             key8: value8,
110             key9: value9,
111         } == expected(
112             value, is_going_to_be="too long to fit in a single line", srsly=True
113         ), "Not what we expected"
114
115         assert {
116             key1: value1,
117             key2: value2,
118             key3: value3,
119             key4: value4,
120             key5: value5,
121             key6: value6,
122             key7: value7,
123             key8: value8,
124             key9: value9,
125         } == expected, (
126             "Not what we expected and the message is too long to fit in one line"
127         )
128
129         assert expected(
130             value, is_going_to_be="too long to fit in a single line", srsly=True
131         ) == {
132             key1: value1,
133             key2: value2,
134             key3: value3,
135             key4: value4,
136             key5: value5,
137             key6: value6,
138             key7: value7,
139             key8: value8,
140             key9: value9,
141         }, "Not what we expected"
142
143         assert expected == {
144             key1: value1,
145             key2: value2,
146             key3: value3,
147             key4: value4,
148             key5: value5,
149             key6: value6,
150             key7: value7,
151             key8: value8,
152             key9: value9,
153         }, (
154             "Not what we expected and the message is too long to fit "
155             "in one line because it's too long"
156         )
157
158         dis_c_instance_method = """\
159         %3d           0 LOAD_FAST                1 (x)
160                       2 LOAD_CONST               1 (1)
161                       4 COMPARE_OP               2 (==)
162                       6 LOAD_FAST                0 (self)
163                       8 STORE_ATTR               0 (x)
164                      10 LOAD_CONST               0 (None)
165                      12 RETURN_VALUE
166         """ % (
167             _C.__init__.__code__.co_firstlineno + 1,
168         )
169
170         assert (
171             expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect
172             == {
173                 key1: value1,
174                 key2: value2,
175                 key3: value3,
176                 key4: value4,
177                 key5: value5,
178                 key6: value6,
179                 key7: value7,
180                 key8: value8,
181                 key9: value9,
182             }
183         )