Table of Contents
1. pytest-html
1.1 PermissionError: [Errno 13] Permission denied: ‘D:\\software\python3\\anconda3\Lib\\site-packages\pytest_html\ __pycache__\tmp_ttoasov’
1.2 Cause of error
2. Retry failed test cases
3. Parallel execution of use cases pytest-parallel
1. pytest-html
The administrator opens Anaconda Prompt and enters: pip install pytest-html
Check whether the installation is successful:
1.1 PermissionError: [Errno 13] Permission denied: ‘D:\software\python3\anconda3\ Lib\site-packages\pytest_html\__pycache__\tmp_ttoasov’
1. Check whether the file under the corresponding path exists and is occupied. If the file does not exist, just find the corresponding file; if the file exists and is occupied, the occupying program will be temporarily closed.
2. Modify the permissions of cmd and run it as administrator.
3. Check whether the folder is open.
hhhhhhh Traceback (most recent call last): File "D:\software\python3\anconda3\lib\tempfile.py", line 256, in _mkstemp_inner fd = _os.open(file, flags, 0o600) PermissionError: [Errno 13] Permission denied: 'D:\\software\python3\\anconda3\Lib\\site-packages\pytest_html\__pycache__ \tmp_ttoasov' During handling of the above exception, another exception occurred:
pytest_html\__pycache__\tmp_ttoasov does not have this file. Delete this folder and try again.
1.2 Error Reason
1. The file is occupied
2. File not found
3. No permission to access
4. What is opened is not a file, but a directory
D:\software\python3\anconda3\Lib
Reference: Python error: PermissionError: [Errno 13] Permission denied solution_python_Script Home
1.3 Solution
Python 3.6 solves & amp;amp;quot;PermissionError: [Errno 13] Permission denied & amp;amp;quot; – Jianshu
Run pycharm as administrator
import pytest if __name__=='__main__': pytest.main(['-s','-v', './test_project','--html=./report/result.html'])
2. Retry failed use cases
(base) C:\WINDOWS\system32>pip install pytest-rerunfailures
pytest -v ./rerunfailures –reruns 10
PS E:\data\web test\Selenium3 automated testing practice - based on Python language\mycode\pytest_example> pytest -v ./rerunfailures --reruns 10 ================================================== ====================== test session starts ========================= =============================================== platform win32 -- Python 3.10.9, pytest-7.1.2, pluggy-1.0.0 -- D:\software\python3\anconda3\python.exe cachedir: .pytest_cache metadata: {'Python': '3.10.9', 'Platform': 'Windows-10-10.0.19045-SP0', 'Packages': {'pytest': '7.1.2', 'pluggy': '1.0.0'}, 'Plugins': {'anyio': '3.5.0', 'html': '4.0 .2', 'metadata': '3.0.0', 'rerunfailures': '12.0'}, 'JAVA_HOME': 'D:\software\\ \Java\jdk1.8.0_151'} rootdir: E:\data\web test\Selenium3 automated testing practice - based on Python language\mycode\pytest_example plugins: anyio-3.5.0, html-4.0.2, metadata-3.0.0, rerunfailures-12.0 collected 1 item rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun RERUN [100%] rerunfailures/test_rerunfailures.py::test_fail_rerun FAILED [100%] ================================================== =========================== FAILURES ====================== ================================================== ====== ____________________________________________________________________________ test_fail_rerun ____________________________________________________________________________ def test_fail_rerun(): > assert 2 + 2==1 E assert (2 + 2) == 1 rerunfailures\test_rerunfailures.py:2: AssertionError ================================================== ==================== short test summary info ========================== ============================================ FAILED rerunfailures/test_rerunfailures.py::test_fail_rerun - assert (2 + 2) == 1 ================================================== ================== 1 failed, 10 rerun in 0.75s ======================== ============================================ PS E:\data\web test\Selenium3 automated testing practice - based on Python language\mycode\pytest_example>
3. Parallel execution of use cases pytest-parallel
pip install pytest-parallel
Run: pytest -q test_paralle.py
Web automation parallel executions may interfere with each other. use less