pydata / pydata/xarray

Remove use of allow_cleanup_failure in test_backends.py

Open
#1,668 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

contrib-good-first-issue contrib-help-wanted topic-testing
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

This exists for the benefit of Windows, on which trying to delete an open file results in an error. But really, it would be nice to have a test suite that doesn't leave any temporary files hanging around.

The main culprit is tests like this, where opening a file triggers an error:

with raises_regex(TypeError, 'pip install netcdf4'):
    open_dataset(tmp_file, engine='scipy')

The way to fix this is to use mocking of some sort, to intercept calls to backend file objects and close them afterwards.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in test_backends.py by locating allow_cleanup_failure and the tests that open files before raising errors, including the open_dataset example with engine='scipy'. Review how backend file objects are handled, then verify the tests use mocking and no longer leave temporary files behind.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.