Closed
Description
As pyfakefs users know, it is very useful for errors and exceptions to mention "fake file system".
While fixing a bug in fakefs related to exceptions, I noticed a nice way to add "fake file system" to the canonical error messages returned by os.strerror()
.
In fake os
, define os.strerror()
as something like this:
def strerror(errno):
return '%s in the fake file system' % os.strerror(errno)
where the os.strerror()
used within the function is the real os.strerror()
.
The English grammar of this message should be correct in all cases. Meanwhile, we can guarantee that startswith()
can be used to detect the error message for both the real and fake file systems:
message = os.strerror(errno.ENOENT)
assert message.startswith('No such file or directory')
Then, all occurrences of literal string messages within pyfakefs should be replaced with the fake os.strerror()
.