How to use the pyfakefs.fake_filesystem.FakeFilesystem.stat function in pyfakefs

To help you get started, we’ve selected a few pyfakefs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kobayashi / s3monkey / s3monkey / pyfakefs / fake_pathlib.py View on Github external
return staticmethod(_wrapped)


def _wrap_binary_strfunc_reverse(strfunc):
    @functools.wraps(strfunc)
    def _wrapped(pathobj1, pathobj2, *args):
        return strfunc(pathobj2.filesystem, str(pathobj2), str(pathobj1), *args)

    return staticmethod(_wrapped)


class _FakeAccessor(pathlib._Accessor):  # pylint: disable=protected-access
    """Accessor which forwards some of the functions to FakeFilesystem methods."""

    stat = _wrap_strfunc(FakeFilesystem.stat)

    lstat = _wrap_strfunc(lambda fs, path: FakeFilesystem.stat(fs, path,
                                                               follow_symlinks=False))

    listdir = _wrap_strfunc(FakeFilesystem.listdir)

    chmod = _wrap_strfunc(FakeFilesystem.chmod)

    if sys.version_info >= (3, 6):
        scandir = _wrap_strfunc(fake_scandir.scandir)

    if hasattr(os, "lchmod"):
        lchmod = _wrap_strfunc(lambda fs, path, mode: FakeFilesystem.chmod(
            fs, path, mode, follow_symlinks=False))
    else:
        def lchmod(self, pathobj, mode):
github jmcgeheeiv / pyfakefs / pyfakefs / fake_pathlib.py View on Github external
pathobj2.filesystem, str(pathobj2), str(pathobj1), *args)

    return staticmethod(_wrapped)


try:
    accessor = pathlib._Accessor
except AttributeError:
    accessor = object


class _FakeAccessor(accessor):
    """Accessor which forwards some of the functions to FakeFilesystem methods.
    """

    stat = _wrap_strfunc(FakeFilesystem.stat)

    lstat = _wrap_strfunc(
        lambda fs, path: FakeFilesystem.stat(fs, path, follow_symlinks=False))

    listdir = _wrap_strfunc(FakeFilesystem.listdir)

    chmod = _wrap_strfunc(FakeFilesystem.chmod)

    if use_scandir:
        scandir = _wrap_strfunc(fake_scandir.scandir)

    if hasattr(os, "lchmod"):
        lchmod = _wrap_strfunc(lambda fs, path, mode: FakeFilesystem.chmod(
            fs, path, mode, follow_symlinks=False))
    else:
        def lchmod(self, pathobj, mode):
github jmcgeheeiv / pyfakefs / pyfakefs / fake_pathlib.py View on Github external
        lambda fs, path: FakeFilesystem.stat(fs, path, follow_symlinks=False))
github kobayashi / s3monkey / s3monkey / pyfakefs / fake_pathlib.py View on Github external
    lstat = _wrap_strfunc(lambda fs, path: FakeFilesystem.stat(fs, path,
                                                               follow_symlinks=False))