$22 GRAYBYTE WORDPRESS FILE MANAGER $49

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.217.100
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cloudlinux/venv/lib/python3.11/site-packages/pyfakefs/

HOME
Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/pyfakefs//pytest_plugin.py
"""A pytest plugin for using pyfakefs as a fixture

When pyfakefs is installed, the "fs" fixture becomes available.

:Usage:

def my_fakefs_test(fs):
    fs.create_file('/var/data/xx1.txt')
    assert os.path.exists('/var/data/xx1.txt')
"""

import contextlib

import py
import pytest
from _pytest import capture

from pyfakefs.fake_filesystem_unittest import Patcher, Pause

try:
    from _pytest import pathlib
except ImportError:
    pathlib = None  # type:ignore[assignment]

Patcher.SKIPMODULES.add(py)
Patcher.SKIPMODULES.add(pytest)
Patcher.SKIPMODULES.add(capture)
if pathlib is not None:
    Patcher.SKIPMODULES.add(pathlib)


@pytest.fixture
def fs(request):
    """Fake filesystem."""
    if hasattr(request, "param"):
        # pass optional parameters via @pytest.mark.parametrize
        patcher = Patcher(*request.param)
    else:
        patcher = Patcher()
    patcher.setUp()
    yield patcher.fs
    patcher.tearDown()


@pytest.fixture(scope="class")
def fs_class(request):
    """Class-scoped fake filesystem fixture."""
    if hasattr(request, "param"):
        patcher = Patcher(*request.param)
    else:
        patcher = Patcher()
    patcher.setUp()
    yield patcher.fs
    patcher.tearDown()


@pytest.fixture(scope="module")
def fs_module(request):
    """Module-scoped fake filesystem fixture."""
    if hasattr(request, "param"):
        patcher = Patcher(*request.param)
    else:
        patcher = Patcher()
    patcher.setUp()
    yield patcher.fs
    patcher.tearDown()


@pytest.fixture(scope="session")
def fs_session(request):
    """Session-scoped fake filesystem fixture."""
    if hasattr(request, "param"):
        patcher = Patcher(*request.param)
    else:
        patcher = Patcher()
    patcher.setUp()
    yield patcher.fs
    patcher.tearDown()


@pytest.hookimpl(tryfirst=True)
def pytest_sessionfinish(session, exitstatus):
    """Make sure that the cache is cleared before the final test shutdown."""
    Patcher.clear_fs_cache()


@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_logreport(report):
    """Make sure that patching is not active during reporting."""
    pause = Patcher.PATCHER is not None and Patcher.PATCHER.is_patching
    context_mgr = Pause(Patcher.PATCHER) if pause else contextlib.nullcontext()
    with context_mgr:
        yield
    if pause and report.when == "teardown":
        # if we get here, we are not in a function scope fixture
        # in this case, we still want to pause patching between the tests
        Patcher.PATCHER.pause()


@pytest.hookimpl(tryfirst=True)
def pytest_runtest_setup(item):
    # resume patcher if not in a function scope
    if Patcher.PATCHER is not None:
        Patcher.PATCHER.resume()


Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
9 Apr 2026 8.31 AM
root / root
0755
__pycache__
--
11 Feb 2026 9.30 AM
root / root
0755
pytest_tests
--
11 Feb 2026 9.30 AM
root / root
0755
tests
--
11 Feb 2026 9.30 AM
root / root
0755
__init__.py
0.055 KB
20 Jan 2026 1.01 PM
root / root
0644
_version.py
0.022 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_file.py
49.826 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_filesystem.py
127.073 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_filesystem_shutil.py
6.636 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_filesystem_unittest.py
52.166 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_io.py
6.306 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_legacy_modules.py
3.81 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_open.py
14.952 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_os.py
54.217 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_path.py
20.329 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_pathlib.py
41.795 KB
20 Jan 2026 1.01 PM
root / root
0644
fake_scandir.py
8.772 KB
20 Jan 2026 1.01 PM
root / root
0644
helpers.py
16.716 KB
20 Jan 2026 1.01 PM
root / root
0644
legacy_packages.py
0.877 KB
20 Jan 2026 1.01 PM
root / root
0644
mox3_stubout.py
5.267 KB
20 Jan 2026 1.01 PM
root / root
0644
patched_packages.py
6.439 KB
20 Jan 2026 1.01 PM
root / root
0644
py.typed
0.066 KB
20 Jan 2026 1.01 PM
root / root
0644
pytest_plugin.py
2.659 KB
20 Jan 2026 1.01 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF