Skip to content

Commit f15c1ac

Browse files
committed
Rearranged test_clean_writer to remove trailing whitespace
1 parent 88b0024 commit f15c1ac

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

tests/test_paths.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,17 @@ def teardown_class(cls):
173173
def test_clean_writer():
174174
with TemporaryDirectory() as tmpdir:
175175
tempfile = pathlib.Path(tmpdir) / "tmpfile.txt"
176+
177+
test_string = "\n".join([
178+
"Top line",
179+
" ",
180+
"Line with whitespace ",
181+
"Line with tabs ",
182+
"No newline at end of file",
183+
])
184+
176185
with tempfile.open("w") as fp:
177-
clean_writer(
178-
"""Top line
179-
180-
Line with whitespace
181-
Line with tabs
182-
No newline at end of file""",
183-
fp
184-
)
186+
clean_writer(test_string, fp)
185187

186188
assert tempfile.read_text() == """Top line
187189
@@ -190,23 +192,16 @@ def test_clean_writer():
190192
No newline at end of file
191193
"""
192194
# Again with lots of newlines
193-
with tempfile.open("w") as fp:
194-
clean_writer(
195-
"""Top line
196-
197-
Line with whitespace
198-
Line with tabs
199-
Too many newlines
200-
201-
195+
test_string = "\n".join([
196+
"Top line",
197+
" ",
198+
"Line with whitespace ",
199+
"Line with tabs ",
200+
"Too many newlines\n\n\n\n\n\n\n",
201+
])
202202

203-
204-
205-
206-
207-
""",
208-
fp
209-
)
203+
with tempfile.open("w") as fp:
204+
clean_writer(test_string, fp)
210205

211206
assert tempfile.read_text() == """Top line
212207

0 commit comments

Comments
 (0)