-
Notifications
You must be signed in to change notification settings - Fork 3
Only install pre-commit hooks in one test #284
Description
Motivation
Now that we have codecov, I can see the slow tests:
https://app.codecov.io/gh/nathanjmcdougall/usethis-python/tests/main?parameter=SLOWEST_TESTS
One thing I identify is that many tests are slow because they are relying on venvs + git repos to be created, in which to install pre-commit so that it can be used to install the hooks. I think we should be able to avoid testing this in most tests, and just skip the pre-commit installation step, testing the alternative message instead. We should still test installation works, but probably in its own test rather than inadvertently with other cases.
Related (and this needs unpacking and perhaps a separate ticket), I suspect there's a way to run a uv command to temporarily install pre-commit so that it can uninstall from git without doing the full uv add and uv remove manoevre where we alternate back and forward. That would be especially good because it means we can generalize some of our use_* functions away from tool-bespoke logic.
Summary of desired enhancement
Speed up tests by only installing pre-commit hooks when absolutely necessary.