I would to test if a system reads and writes files correctly (text mode / binary mode) on multiple platforms, at least on linux and windows. (Using pytest).
See https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
It is possible to mock a filesystem with pyfakefs, for example. But I have not been able to find a mock for simulating the windows behaviour with files opened in text mode, when running the tests on linux.
Is it possible to force the translation of eol (\r\n to \n) in text mode, running on linux?
Just stumbled over this - while this is an old question, maybe the answer will help someone else... In pyfakefs, you can change your fake file system, e.g. (example in pytest):
In current pyfakefs versions, there is a more comprehensive method to change the fake OS - you can set
osinstead ofis_windows_fs. This changes a few more properties (like the path delimiter and the case sensitivity) to match the selected OS. Here is an example from the documentation, which shall also run under Linux:OSTypeis an enum with the possible valuesOSType.WINDOWS,OSType.LINUXandOSType.MACOS.