Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]PermissionError: [WinError 5] #224

Open
zhaod34 opened this issue Apr 29, 2024 · 0 comments
Open

[BUG]PermissionError: [WinError 5] #224

zhaod34 opened this issue Apr 29, 2024 · 0 comments

Comments

@zhaod34
Copy link

zhaod34 commented Apr 29, 2024

Context

windows 11
python 3.12.2
pytest 7.4
playwright-pytest 0.4.4
pytest-xdist 3.5.0

run
pytest -n 3 test_case

Sometimes report the error:


[gw1] win32 -- Python 3.12.2 C:\Users\Administrator\.virtualenvs\ehr_autotest-ViGcsCVN\Scripts\python.exe

pytestconfig = <_pytest.config.Config object at 0x000001C68B1B51C0>

    @pytest.fixture(scope="session", autouse=True)
    def delete_output_dir(pytestconfig: Any) -> None:
        output_dir = pytestconfig.getoption("--output")
        if os.path.exists(output_dir):
            try:
>               shutil.rmtree(output_dir)

C:\Users\Administrator\.virtualenvs\ehr_autotest-ViGcsCVN\Lib\site-packages\pytest_playwright\pytest_playwright.py:45:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _  
..\..\Python312\Lib\shutil.py:820: in rmtree
    return _rmtree_unsafe(path, onexc)
..\..\Python312\Lib\shutil.py:643: in _rmtree_unsafe
    _rmtree_unsafe(fullname, onexc)
..\..\Python312\Lib\shutil.py:652: in _rmtree_unsafe
    onexc(os.rmdir, path, err)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

path = 'test-results\\test-case-organization-organization-test-add-organization-py-test-add-organization-default-user-chromium'
onexc = <function rmtree.<locals>.onexc at 0x000001C69C85E020>

    def _rmtree_unsafe(path, onexc):
        try:
            with os.scandir(path) as scandir_it:
                entries = list(scandir_it)
        except OSError as err:
            onexc(os.scandir, path, err)
            entries = []
        for entry in entries:
            fullname = entry.path
            try:
                is_dir = entry.is_dir(follow_symlinks=False)
            except OSError:
                is_dir = False

            if is_dir and not entry.is_junction():
                try:
                    if entry.is_symlink():
                        # This can only happen if someone replaces
                        # a directory with a symlink after the call to
                        # os.scandir or entry.is_dir above.
                        raise OSError("Cannot call rmtree on a symbolic link")
                except OSError as err:
                    onexc(os.path.islink, fullname, err)
                    continue
                _rmtree_unsafe(fullname, onexc)
            else:
                try:
                    os.unlink(fullname)
                except OSError as err:
                    onexc(os.unlink, fullname, err)
        try:
>           os.rmdir(path)
E           PermissionError: [WinError 5] 拒绝访问。: 'test-results\\test-case-organization-organization-test-add-organization-py-test-add-organization-default-user-chromium'

..\..\Python312\Lib\shutil.py:650: PermissionError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant