Skip to content

Use pytest tmp file management fixtures instead of ensure_clean[_path|_dir] #26984

Closed
@jgehrcke

Description

@jgehrcke

Opened as of discussion in #26818.

tests/io/test_pytables.py uses a context manager called ensure_clean_path. It might be worth using the pytest tmp_path fixture instead which I think provides everything we need with less code (also easier to understand for new contributors familiar with pytest). And it provides even a little more functionality, comparison:

  • it guarantees file system isolation between tests (as does ensure_clean_path).
  • it makes it obvious which file belongs to which test via expressive naming (as opposed to ensure_clean_path).
  • it retains files for later inspection as opposed to ensure_clean_path. That can be useful for debugging after test failure.

Note: the pytest-managed temp files are removed in a rolling fashion across test runner invocations so that storage space requirement does not grow indefinitely with the number of invocations.

Cf. comment #26818 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementIO DataIO issues that don't fit into a more specific labelTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions