Skip to content

Spec for fake os.strerror() #202

Closed
Closed
@jmcgeheeiv

Description

@jmcgeheeiv

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().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions