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

c83db1d44ee33adbec43e904e6be61237252a552
[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         assignment = (
47             some.rather.elaborate.rule() and another.rule.ending_with.index[123]
48         )
49
50     def easy_asserts(self) -> None:
51         assert {
52             key1: value1,
53             key2: value2,
54             key3: value3,
55             key4: value4,
56             key5: value5,
57             key6: value6,
58             key7: value7,
59             key8: value8,
60             key9: value9,
61         } == expected, "Not what we expected"
62
63         assert expected == {
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         }, "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         }
86
87     def tricky_asserts(self) -> None:
88         assert {
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         } == expected(
99             value, is_going_to_be="too long to fit in a single line", srsly=True
100         ), "Not what we expected"
101
102         assert {
103             key1: value1,
104             key2: value2,
105             key3: value3,
106             key4: value4,
107             key5: value5,
108             key6: value6,
109             key7: value7,
110             key8: value8,
111             key9: value9,
112         } == expected, (
113             "Not what we expected and the message is too long to fit in one line"
114         )
115
116         assert expected(
117             value, is_going_to_be="too long to fit in a single line", srsly=True
118         ) == {
119             key1: value1,
120             key2: value2,
121             key3: value3,
122             key4: value4,
123             key5: value5,
124             key6: value6,
125             key7: value7,
126             key8: value8,
127             key9: value9,
128         }, "Not what we expected"
129
130         assert expected == {
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         }, (
141             "Not what we expected and the message is too long to fit "
142             "in one line because it's too long"
143         )
144
145         # This is weird but true.
146         assert expectedexpectedexpectedexpectedexpectedexpectedexpectedexpectedexpect == {
147             key1: value1,
148             key2: value2,
149             key3: value3,
150             key4: value4,
151             key5: value5,
152             key6: value6,
153             key7: value7,
154             key8: value8,
155             key9: value9,
156         }