Skip to content
Myr

Fix test_edit to work with BSD sed (#3129)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rowlando13 · committed by GitHub · parents 0b5c6b7, bd131e1 · Browse files · 1 file+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−2 removed

  • tests:+9 added−2 removed

1 file+9 added−2 removed

modified:tests/test_termui.py+9 added-2 removed
384 unmodified lines
385386@pytest.mark.skipif(platform.system() == "Windows", reason="No sed on Windows.")387def test_edit(runner):388 with tempfile.NamedTemporaryFile(mode="w") as named_tempfile:389 named_tempfile.write("a\nb")389 named_tempfile.write("a\nb\n")390 named_tempfile.flush()391392 result = click.edit(filename=named_tempfile.name, editor="sed -i~ 's/$/Test/'")393 assert result is None394395 # We need ot reopen the file as it becomes unreadable after the edit.396 with open(named_tempfile.name) as reopened_file:397 # POSIX says that when sed writes a pattern space to output then it398 # is immediately followed by a newline and so the expected result399 # should contain the newline. However, some sed implementations400 # (e.g. GNU sed) does not terminate the last line in the output401 # with the newline in a case the input data missed newline at the402 # end of last line. Hence the input data (see above) should be403 # terminated by newline too.397 assert reopened_file.read() == "aTest\nbTest"404 assert reopened_file.read() == "aTest\nbTest\n"405406407@pytest.mark.parametrize(408 ("prompt_required", "required", "args", "expect"),
304 unmodified lines