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

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