]> git.madduck.net Git - etc/vim.git/blob - tests/data/preview/multiline_strings.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:

Remove unneeded mypy dependencies (#3783)
[etc/vim.git] / tests / data / preview / multiline_strings.py
1 """cow
2 say""",
3 call(3, "dogsay", textwrap.dedent("""dove
4     coo""" % "cowabunga"))
5 call(3, "dogsay", textwrap.dedent("""dove
6 coo""" % "cowabunga"))
7 call(3, textwrap.dedent("""cow
8     moo""" % "cowabunga"), "dogsay")
9 call(3, "dogsay", textwrap.dedent("""crow
10     caw""" % "cowabunga"),)
11 call(3, textwrap.dedent("""cat
12     meow""" % "cowabunga"), {"dog", "say"})
13 call(3, {"dog", "say"}, textwrap.dedent("""horse
14     neigh""" % "cowabunga"))
15 call(3, {"dog", "say"}, textwrap.dedent("""pig
16     oink""" % "cowabunga"),)
17 textwrap.dedent("""A one-line triple-quoted string.""")
18 textwrap.dedent("""A two-line triple-quoted string
19 since it goes to the next line.""")
20 textwrap.dedent("""A three-line triple-quoted string
21 that not only goes to the next line
22 but also goes one line beyond.""")
23 textwrap.dedent("""\
24     A triple-quoted string
25     actually leveraging the textwrap.dedent functionality
26     that ends in a trailing newline,
27     representing e.g. file contents.
28 """)
29 path.write_text(textwrap.dedent("""\
30     A triple-quoted string
31     actually leveraging the textwrap.dedent functionality
32     that ends in a trailing newline,
33     representing e.g. file contents.
34 """))
35 path.write_text(textwrap.dedent("""\
36     A triple-quoted string
37     actually leveraging the textwrap.dedent functionality
38     that ends in a trailing newline,
39     representing e.g. {config_filename} file contents.
40 """.format("config_filename", config_filename)))
41 # Another use case
42 data = yaml.load("""\
43 a: 1
44 b: 2
45 """)
46 data = yaml.load("""\
47 a: 1
48 b: 2
49 """,)
50 data = yaml.load(
51     """\
52     a: 1
53     b: 2
54 """
55 )
56
57 MULTILINE = """
58 foo
59 """.replace("\n", "")
60 generated_readme = lambda project_name: """
61 {}
62
63 <Add content here!>
64 """.strip().format(project_name)
65 parser.usage += """
66 Custom extra help summary.
67
68 Extra test:
69 - with
70 - bullets
71 """
72
73
74 def get_stuff(cr, value):
75     # original
76     cr.execute("""
77         SELECT whatever
78           FROM some_table t
79          WHERE id = %s
80     """, [value])
81     return cr.fetchone()
82
83
84 def get_stuff(cr, value):
85     # preferred
86     cr.execute(
87         """
88         SELECT whatever
89           FROM some_table t
90          WHERE id = %s
91         """,
92         [value],
93     )
94     return cr.fetchone()
95
96
97 call(arg1, arg2, """
98 short
99 """, arg3=True)
100 test_vectors = [
101     "one-liner\n",
102     "two\nliner\n",
103     """expressed
104 as a three line
105 mulitline string""",
106 ]
107
108 _wat = re.compile(
109     r"""
110     regex
111     """,
112     re.MULTILINE | re.VERBOSE,
113 )
114 dis_c_instance_method = """\
115 %3d           0 LOAD_FAST                1 (x)
116               2 LOAD_CONST               1 (1)
117               4 COMPARE_OP               2 (==)
118               6 LOAD_FAST                0 (self)
119               8 STORE_ATTR               0 (x)
120              10 LOAD_CONST               0 (None)
121              12 RETURN_VALUE
122 """ % (_C.__init__.__code__.co_firstlineno + 1,)
123 path.write_text(textwrap.dedent("""\
124     A triple-quoted string
125     actually {verb} the textwrap.dedent functionality
126     that ends in a trailing newline,
127     representing e.g. {file_type} file contents.
128 """.format(verb="using", file_type="test")))
129 {"""cow
130 moos"""}
131 ["""cow
132 moos"""]
133 ["""cow
134 moos""", """dog
135 woofs
136 and
137 barks"""]
138 def dastardly_default_value(
139     cow: String = json.loads("""this
140 is
141 quite
142 the
143 dastadardly
144 value!"""),
145     **kwargs,
146 ):
147     pass
148
149 print(f"""
150     This {animal}
151     moos and barks
152 {animal} say
153 """)
154 msg = f"""The arguments {bad_arguments} were passed in.
155 Please use `--build-option` instead,
156 `--global-option` is reserved to flags like `--verbose` or `--quiet`.
157 """
158
159 # output
160 """cow
161 say""",
162 call(
163     3,
164     "dogsay",
165     textwrap.dedent("""dove
166     coo""" % "cowabunga"),
167 )
168 call(
169     3,
170     "dogsay",
171     textwrap.dedent("""dove
172 coo""" % "cowabunga"),
173 )
174 call(
175     3,
176     textwrap.dedent("""cow
177     moo""" % "cowabunga"),
178     "dogsay",
179 )
180 call(
181     3,
182     "dogsay",
183     textwrap.dedent("""crow
184     caw""" % "cowabunga"),
185 )
186 call(
187     3,
188     textwrap.dedent("""cat
189     meow""" % "cowabunga"),
190     {"dog", "say"},
191 )
192 call(
193     3,
194     {"dog", "say"},
195     textwrap.dedent("""horse
196     neigh""" % "cowabunga"),
197 )
198 call(
199     3,
200     {"dog", "say"},
201     textwrap.dedent("""pig
202     oink""" % "cowabunga"),
203 )
204 textwrap.dedent("""A one-line triple-quoted string.""")
205 textwrap.dedent("""A two-line triple-quoted string
206 since it goes to the next line.""")
207 textwrap.dedent("""A three-line triple-quoted string
208 that not only goes to the next line
209 but also goes one line beyond.""")
210 textwrap.dedent("""\
211     A triple-quoted string
212     actually leveraging the textwrap.dedent functionality
213     that ends in a trailing newline,
214     representing e.g. file contents.
215 """)
216 path.write_text(textwrap.dedent("""\
217     A triple-quoted string
218     actually leveraging the textwrap.dedent functionality
219     that ends in a trailing newline,
220     representing e.g. file contents.
221 """))
222 path.write_text(textwrap.dedent("""\
223     A triple-quoted string
224     actually leveraging the textwrap.dedent functionality
225     that ends in a trailing newline,
226     representing e.g. {config_filename} file contents.
227 """.format("config_filename", config_filename)))
228 # Another use case
229 data = yaml.load("""\
230 a: 1
231 b: 2
232 """)
233 data = yaml.load(
234     """\
235 a: 1
236 b: 2
237 """,
238 )
239 data = yaml.load("""\
240     a: 1
241     b: 2
242 """)
243
244 MULTILINE = """
245 foo
246 """.replace("\n", "")
247 generated_readme = lambda project_name: """
248 {}
249
250 <Add content here!>
251 """.strip().format(project_name)
252 parser.usage += """
253 Custom extra help summary.
254
255 Extra test:
256 - with
257 - bullets
258 """
259
260
261 def get_stuff(cr, value):
262     # original
263     cr.execute(
264         """
265         SELECT whatever
266           FROM some_table t
267          WHERE id = %s
268     """,
269         [value],
270     )
271     return cr.fetchone()
272
273
274 def get_stuff(cr, value):
275     # preferred
276     cr.execute(
277         """
278         SELECT whatever
279           FROM some_table t
280          WHERE id = %s
281         """,
282         [value],
283     )
284     return cr.fetchone()
285
286
287 call(
288     arg1,
289     arg2,
290     """
291 short
292 """,
293     arg3=True,
294 )
295 test_vectors = [
296     "one-liner\n",
297     "two\nliner\n",
298     """expressed
299 as a three line
300 mulitline string""",
301 ]
302
303 _wat = re.compile(
304     r"""
305     regex
306     """,
307     re.MULTILINE | re.VERBOSE,
308 )
309 dis_c_instance_method = """\
310 %3d           0 LOAD_FAST                1 (x)
311               2 LOAD_CONST               1 (1)
312               4 COMPARE_OP               2 (==)
313               6 LOAD_FAST                0 (self)
314               8 STORE_ATTR               0 (x)
315              10 LOAD_CONST               0 (None)
316              12 RETURN_VALUE
317 """ % (_C.__init__.__code__.co_firstlineno + 1,)
318 path.write_text(textwrap.dedent("""\
319     A triple-quoted string
320     actually {verb} the textwrap.dedent functionality
321     that ends in a trailing newline,
322     representing e.g. {file_type} file contents.
323 """.format(verb="using", file_type="test")))
324 {"""cow
325 moos"""}
326 ["""cow
327 moos"""]
328 [
329     """cow
330 moos""",
331     """dog
332 woofs
333 and
334 barks""",
335 ]
336
337
338 def dastardly_default_value(
339     cow: String = json.loads("""this
340 is
341 quite
342 the
343 dastadardly
344 value!"""),
345     **kwargs,
346 ):
347     pass
348
349
350 print(f"""
351     This {animal}
352     moos and barks
353 {animal} say
354 """)
355 msg = f"""The arguments {bad_arguments} were passed in.
356 Please use `--build-option` instead,
357 `--global-option` is reserved to flags like `--verbose` or `--quiet`.
358 """