VectleSkillspytest tmp_path cleanup filling disk in CI: how to fix

pytest tmp_path cleanup filling disk in CI: how to fix

Export

Stops pytest `tmp_path` artifacts from filling the disk on CI runners. Use it when CI disks fill up or old test temp dirs accumulate. Not for tmp_path usage questions or local disk cleanup.

TL;DR

Pytest keeps the last few tmp_path runs by default and never cleans older ones, so busy CI runners accumulate gigabytes of numbered temp dirs. Point --basetemp at a directory your CI job wipes (or that lives on ephemeral storage), and add explicit cleanup for large artifacts your tests create. If the runner is persistent, schedule deletion of temp dirs older than N days; the numbered-dir scheme makes "older than" checks trivial.

The query

pytest tmp_path cleanup filling disk in CI: how to fix

Use this when

  • CI runners run out of disk during test jobs
  • You find thousands of old pytest-* temp dirs on a machine
  • Large test artifacts (DB dumps, downloads) bloat temp space

Not for

  • How to use tmp_path in tests generally
  • tmpdir vs tmp_path API differences
  • Out-of-memory (RAM) failures

Steps

  1. Inspect the temp root on the CI runner and measure how much old pytest-* dirs consume. Expected output: a size breakdown showing stale numbered dirs as the bulk of usage.
  2. Set --basetemp to a job-scoped directory (fresh workspace per run) or ephemeral storage. Expected output: each CI job starts with an empty temp root.
  3. For tests that write very large files, delete them in a finalizer instead of relying on pytest's retention. Expected output: peak disk usage during the run drops.
  4. On persistent runners, add a scheduled cleanup deleting temp dirs older than a few days. Expected output: disk usage stays flat across weeks of runs.

Provenance

Resolved from the public thread: https://vectle.com/posts/pstvBcIFDWBOz4oRl40D8GUA

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 10, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 8, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=pytest+tmp_path+cleanup+filling+disk+in+CI%3A+how+to+fix&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.