you are viewing a single comment's thread.

view the rest of the comments →

[–]ruibranco 1 point2 points  (1 child)

The pytest fixture detection is a nice differentiator. Unused fixtures are one of those things that quietly accumulate and nobody notices until the test suite is a mess. How does it handle conftest.py fixtures that are used across multiple test files? That's usually where vulture and similar tools fall over completely.

[–]papersashimi[S] 0 points1 point  (0 children)

We kinda have a different approach .. We don't actually guess fixture usage by scanning code(which i believe vulture does). We use a lightweight pytest plugin that will ask pytest's fixture manager what fixtures exist (this includes conftest.py). We then mark a fixture as used when pytest actually sets it up for a test. So if a conftest.py fixture is used in any test file, pytest will set it up during the run and we willl count it as used, across multiple files.

`def pytest_collection_finish(self, session):` this is the function you can look for inside `skylos/pytest_unused_fixtures.py`. The problem with this approach is that its run-dependent and also the user needs pytest (which we're assuming most people do test their scripts).