Clean up read-only runtime cache trees after tests

Open Beginner friendly
#217 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
testing

Research direction

Start with the discard_tree() helper in tests/plugin_testing.py to see how it restores write permissions before removal. Then grep the tests for shutil.rmtree calls using ignore_errors=True and switch the temporary runtime cache cleanup to discard_tree(). Done when those tests remove the read-only cache trees without leaving directories behind when run as an unprivileged user.

Written by the indexing model from the issue text.

Description

app: scripts Bucket: KTLO status: backlog type: housekeeping
Proposed Changes

Use the existing discard_tree() helper from tests/plugin_testing.py to clean up temporary runtime cache directories created by tests.

Justification

The runtime cache intentionally makes published revision trees read-only. Several tests use shutil.rmtree() with ignore_errors=True for cleanup, which silently leaves these trees behind when running as an unprivileged user.

Reusing discard_tree() ensures that write permissions are restored before removal and prevents temporary directories from accumulating across repeated test runs.

Dominant language
Python
Stars
8
Forks
0
Avg merge
13h 4m
Merged PRs (30d)
77

Getting set up

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.

More from netbox-community/netbox-scripts

All issues in netbox-community/netbox-scripts

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.