Skip to content

Module scoped pytest fixture raises error #684

@iSplasher

Description

@iSplasher

Describe the bug
Hello, when I try to create this

@pytest.fixture(scope="module")
def fs_module():
    patcher = Patcher()
    patcher.setUp()
    yield patcher.fs
    patcher.tearDown()

I get this error when the function yields

p = WindowsPath('D:/TEMP/pytest-of-User/pytest-9')

    def create_cleanup_lock(p: Path) -> Path:
        """Create a lock to prevent premature folder cleanup."""
        lock_path = get_lock_path(p)
        try:
>           fd = os.open(str(lock_path), os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o644)
E           FileNotFoundError: [Errno 2] No such file or directory: 'D:\\TEMP\\pytest-of-User\\pytest-9\\.lock'

C:\dev\code\env\lib\site-packages\_pytest\pathlib.py:234: FileNotFoundError

Your environment
Please run the following and paste the output.

- Windows-10-10.0.22000-SP0
- Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)]
- pyfakefs 4.5.6
- pytest 7.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions