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

For omitting optional parentheses, ignore delimiters of lower priorities
[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
36     def omitting_trailers(self) -> None:
37         get_collection(
38             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
39         )[OneLevelIndex]
40         get_collection(
41             hey_this_is_a_very_long_call, it_has_funny_attributes, really=True
42         )[OneLevelIndex][TwoLevelIndex][ThreeLevelIndex][FourLevelIndex]
43         d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][
44             22
45         ]
46
47     def easy_asserts(self) -> None:
48         assert {
49             key1: value1,
50             key2: value2,
51             key3: value3,
52             key4: value4,
53             key5: value5,
54             key6: value6,
55             key7: value7,
56             key8: value8,
57             key9: value9,
58         } == expected, "Not what we expected"
59
60         assert expected == {
61             key1: value1,
62             key2: value2,
63             key3: value3,
64             key4: value4,
65             key5: value5,
66             key6: value6,
67             key7: value7,
68             key8: value8,
69             key9: value9,
70         }, "Not what we expected"
71
72         assert expected == {
73             key1: value1,
74             key2: value2,
75             key3: value3,
76             key4: value4,
77             key5: value5,
78             key6: value6,
79             key7: value7,
80             key8: value8,
81             key9: value9,
82         }
83
84     def tricky_asserts(self) -> None:
85         assert {
86             key1: value1,
87             key2: value2,
88             key3: value3,
89             key4: value4,
90             key5: value5,
91             key6: value6,
92             key7: value7,
93             key8: value8,
94             key9: value9,
95         } == expected(
96             value, is_going_to_be="too long to fit in a single line", srsly=True
97         ), "Not what we expected"
98
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             "Not what we expected and the message is too long to fit in one line"
111         )
112
113         assert expected(
114             value, is_going_to_be="too long to fit in a single line", srsly=True
115         ) == {
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         }, "Not what we expected"
126
127         assert expected == {
128             key1: value1,
129             key2: value2,
130             key3: value3,
131             key4: value4,
132             key5: value5,
133             key6: value6,
134             key7: value7,
135             key8: value8,
136             key9: value9,
137         }, (
138             "Not what we expected and the message is too long to fit "
139             "in one line because it's too long"
140         )
141
142         # This is weird but true.
143         assert expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect == {
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         }