Skip to content

Commit f40d7ab

Browse files
authored
test: split format tests into multiple files (#246)
* test: split format tests into separate files * test: move test docstrings to data file * test: move format docstring classes to separate files * test: new test docstring files * test: split format_code test classes into separate files * test: move test docstrings to toml data files
1 parent 14c71b6 commit f40d7ab

26 files changed

+5884
-4186
lines changed
Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
[one_line]
2+
instring='''def foo():
3+
"""
4+
Hello foo.
5+
"""'''
6+
outstring='''def foo():
7+
"""Hello foo."""'''
8+
9+
[module_docstring]
10+
instring='''#!/usr/env/bin python
11+
"""This is
12+
a module
13+
docstring.
14+
15+
1. One
16+
2. Two
17+
"""
18+
19+
"""But
20+
this
21+
is
22+
not."""'''
23+
outstring='''#!/usr/env/bin python
24+
"""This is a module docstring.
25+
26+
1. One
27+
2. Two
28+
"""
29+
30+
"""But
31+
this
32+
is
33+
not."""'''
34+
35+
[newline_module_variable]
36+
instring='''
37+
CONST = 123
38+
39+
"""docstring for CONST."""
40+
'''
41+
outstring='''
42+
CONST = 123
43+
"""docstring for CONST."""
44+
'''
45+
46+
[class_docstring]
47+
instring='''
48+
class TestClass:
49+
"""This is a class docstring.
50+
:cvar test_int: a class attribute.
51+
..py.method: big_method()
52+
"""
53+
'''
54+
outstring='''
55+
class TestClass:
56+
"""This is a class docstring.
57+
58+
:cvar test_int: a class attribute.
59+
..py.method: big_method()
60+
"""
61+
'''
62+
63+
[newline_class_variable]
64+
instring='''
65+
class TestClass:
66+
67+
"""This is a class docstring."""
68+
69+
test_var = 0
70+
71+
"""This is a class variable docstring."""
72+
73+
test_var2 = 1
74+
75+
76+
"""This is a second class variable docstring."""
77+
'''
78+
outstring='''
79+
class TestClass:
80+
"""This is a class docstring."""
81+
82+
test_var = 0
83+
"""This is a class variable docstring."""
84+
85+
test_var2 = 1
86+
"""This is a second class variable docstring."""
87+
'''
88+
89+
[newline_outside_docstring]
90+
instring='''
91+
def new_function():
92+
"""Description of function."""
93+
found = next(
94+
(index for index, line in enumerate(split) if line.strip()), 0
95+
)
96+
97+
return "\n".join(split[found:])
98+
'''
99+
outstring='''
100+
def new_function():
101+
"""Description of function."""
102+
found = next(
103+
(index for index, line in enumerate(split) if line.strip()), 0
104+
)
105+
106+
return "\n".join(split[found:])
107+
'''
108+
109+
[preserve_line_ending]
110+
instring='''
111+
def foo():\r
112+
"""\r
113+
Hello\r
114+
foo. This is a docstring.\r
115+
"""\r
116+
'''
117+
outstring='''def foo():\r
118+
"""\r
119+
Hello\r
120+
foo. This is a docstring.\r
121+
"""\r
122+
'''
123+
124+
[issue_51]
125+
instring='''def my_func():
126+
127+
"""Summary of my function."""
128+
pass'''
129+
outstring='''def my_func():
130+
"""Summary of my function."""
131+
pass'''
132+
133+
[issue_51_2]
134+
instring='''
135+
def crash_rocket(location): # pragma: no cover
136+
"""This is a docstring following an in-line comment."""
137+
return location'''
138+
outstring='''
139+
def crash_rocket(location): # pragma: no cover
140+
"""This is a docstring following an in-line comment."""
141+
return location'''
142+
143+
[issue_97]
144+
instring='''def pytest_addoption(parser: pytest.Parser) -> "
145+
None:
146+
register_toggle.pytest_addoption(parser)
147+
'''
148+
outstring='''def pytest_addoption(parser: pytest.Parser) -> "
149+
None:
150+
register_toggle.pytest_addoption(parser)
151+
'''
152+
153+
[issue_97_2]
154+
instring='''def pytest_addoption(parser: pytest.Parser) ->
155+
None: # pragma: no cover
156+
157+
register_toggle.pytest_addoption(parser)
158+
'''
159+
outstring='''def pytest_addoption(parser: pytest.Parser) ->
160+
None: # pragma: no cover
161+
162+
register_toggle.pytest_addoption(parser)
163+
'''
164+
165+
[issue_130]
166+
instring='''
167+
class TestClass:
168+
169+
"""This is a class docstring."""
170+
171+
def test_method(self):
172+
173+
"""This is a method docstring.
174+
175+
With a long description followed by two blank lines.
176+
"""
177+
178+
179+
pass
180+
'''
181+
outstring='''
182+
class TestClass:
183+
"""This is a class docstring."""
184+
185+
def test_method(self):
186+
"""This is a method docstring.
187+
188+
With a long description followed by two blank lines.
189+
"""
190+
pass
191+
'''
192+
193+
[issue_139]
194+
instring='''
195+
class TestClass:
196+
197+
"""This is a class docstring.
198+
:cvar test_int: a class attribute.
199+
..py.method: big_method()
200+
"""
201+
'''
202+
outstring='''
203+
class TestClass:
204+
"""This is a class docstring.
205+
206+
:cvar test_int: a class attribute.
207+
..py.method: big_method()
208+
"""
209+
'''
210+
211+
[issue_139_2]
212+
instring="""
213+
class TestClass:
214+
215+
variable = 1
216+
"""
217+
outstring="""
218+
class TestClass:
219+
220+
variable = 1
221+
"""
222+
223+
[issue_156]
224+
instring='''
225+
def test_wps3_process_step_io_data_or_href():
226+
"""Validates that \'data\' literal values and \'href\' file references are both
227+
handled as input for workflow steps corresponding to a WPS-3 process."""
228+
229+
def mock_wps_request(method, url, *_, **kwargs):
230+
nonlocal test_reached_parse_inputs
231+
232+
method = method.upper()
233+
'''
234+
outstring='''
235+
def test_wps3_process_step_io_data_or_href():
236+
"""Validates that \'data\' literal values and \'href\' file references are
237+
both handled as input for workflow steps corresponding to a WPS-3
238+
process."""
239+
240+
def mock_wps_request(method, url, *_, **kwargs):
241+
nonlocal test_reached_parse_inputs
242+
243+
method = method.upper()
244+
'''
245+
246+
[issue_156_173]
247+
instring='''
248+
class Foo:
249+
250+
@abstractmethod
251+
def bar(self):
252+
253+
"""This is a description."""
254+
255+
@abstractmethod
256+
def baz(self):
257+
258+
"""This is a second description."""
259+
260+
'''
261+
outstring='''
262+
class Foo:
263+
264+
@abstractmethod
265+
def bar(self):
266+
"""This is a description."""
267+
268+
@abstractmethod
269+
def baz(self):
270+
"""This is a second description."""
271+
272+
'''
273+
274+
[issue_187]
275+
instring='''
276+
#!/usr/bin/env python
277+
278+
"""a.py"""
279+
'''
280+
outstring='''
281+
#!/usr/bin/env python
282+
283+
"""a.py."""
284+
'''
285+
286+
[issue_203]
287+
instring='''
288+
#!/usr/bin/env python
289+
290+
import os
291+
from typing import Iterator
292+
293+
"""Don't remove this comment, it's cool."""
294+
IMPORTANT_CONSTANT = "potato"
295+
'''
296+
outstring='''
297+
#!/usr/bin/env python
298+
299+
import os
300+
from typing import Iterator
301+
302+
"""Don't remove this comment, it's cool."""
303+
IMPORTANT_CONSTANT = "potato"
304+
'''

0 commit comments

Comments
 (0)