Test Results directory in setup fails intermittently
See original GitHub issueThis issue is not consistent, but sometimes the Test Results directories are not created or, at least, not created in time causing the setup to fail. This looks like an issue with race conditions, but right now we have
- pytest-xdist
- pytest-parallel
as the two plugins that allow you to run tests in parallel. This feature is considered “legacy” since it was one of the first features written. These folders were used to store log files and screenshots for each test, but logging now happens via the logging
module so now these folders are only used for screenshots if the test fails.
So, we can either fix this issue, or we can create a new Feature Request suggesting a better, cleaner way to report logs and screenshots on failure.
project_root = '/home/runner/work/pyleniumio/pyleniumio'
request = <SubRequest 'test_run' for <Function test_element_parent_and_siblings>>
@pytest.fixture(scope='session', autouse=True)
def test_run(project_root, request) -> str:
""" Creates the `/test_results` directory to store the results of the Test Run.
Returns:
The `/test_results` directory as a filepath (str).
"""
session = request.node
test_results_dir = f'{project_root}/test_results'
if os.path.exists(test_results_dir):
# delete /test_results from previous Test Run
shutil.rmtree(test_results_dir, ignore_errors=True)
if not os.path.exists(test_results_dir):
# create /test_results for this Test Run
make_dir(test_results_dir)
for test in session.items:
# make the test_result directory for each test
> make_dir(f'{test_results_dir}/{test.name}')
conftest.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
filepath = '/home/runner/work/pyleniumio/pyleniumio/test_results/test_element_with_no_siblings'
def make_dir(filepath) -> bool:
""" Make a directory.
Returns:
True if successful, False if not.
"""
try:
> os.mkdir(filepath)
E FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/work/pyleniumio/pyleniumio/test_results/test_element_with_no_siblings'
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Why are all my Visual Studio test results "Not executed"
Open the Visual Studio command prompt · Change to the directory where the binary output of your test project is. · Type mstest...
Read more >How to Find Failures Faster in Jenkins Test Results - TotalView
Diagnosing and fixing failures in Jenkins test results is time ... Intermittent failures: The test failure is intermittent and hard to ...
Read more >Intermittent failure of Azure AD Connect directory ...
I have an installation of Azure AD Connect on an on-premises server that has been running error-free for several years. It has suddenly...
Read more >Active Directory ADCs intermittently fail with 'LDAP response ...
Issue. Active Directory ADCs intermittently fail with the following error when reading data (users and/or groups):. LDAP response read timed out.
Read more >Why do Apex Unit Test CLASSES sometimes FAIL when all ...
To resolve: click the "View Test History" link on this page, then press the "Clear Test Results" button as many times as it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@chingc I believe I’ve fixed this issue in
v1.12.5
, but I’d love for you to try it out! I always appreciate your feedback 😄@ElSnoMan Nevermind, I just hit this today. 😦
I’m running using
pytest -n 5
so I think what’s happening is the 5 workers clobbering each other.I think the race condition is happening between the time
Path
is checking to see if the file exists and when it attempts to create it. I think adding a try/except might fix this problem for good. For example:Below is the error I got.