While writing some tests, i got stuck on some weird behavior. I finally narrow the problem to file opening. For instance, this one, my.dat
:
one line
two lines and no final line break
I then ran that python code:
with open('my.dat') as fd:
assert fd.read()[-1] == '\n'
With both python 3 and 2, this code does not raise any AssertError.
My question is: why forcing the presence of line jump at the end of files ?