File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -386,15 +386,22 @@ def test_fast_edit(runner):
386386@pytest .mark .skipif (platform .system () == "Windows" , reason = "No sed on Windows." )
387387def test_edit (runner ):
388388 with tempfile .NamedTemporaryFile (mode = "w" ) as named_tempfile :
389- named_tempfile .write ("a\n b" )
389+ named_tempfile .write ("a\n b\n " )
390390 named_tempfile .flush ()
391391
392392 result = click .edit (filename = named_tempfile .name , editor = "sed -i~ 's/$/Test/'" )
393393 assert result is None
394394
395395 # We need ot reopen the file as it becomes unreadable after the edit.
396396 with open (named_tempfile .name ) as reopened_file :
397- assert reopened_file .read () == "aTest\n bTest"
397+ # POSIX says that when sed writes a pattern space to output then it
398+ # is immediately followed by a newline and so the expected result
399+ # should contain the newline. However, some sed implementations
400+ # (e.g. GNU sed) does not terminate the last line in the output
401+ # with the newline in a case the input data missed newline at the
402+ # end of last line. Hence the input data (see above) should be
403+ # terminated by newline too.
404+ assert reopened_file .read () == "aTest\n bTest\n "
398405
399406
400407@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments