ipwnponies / pytest-antilru

Bust functools.lru_cache when running pytest to avoid test pollution
MIT License
20 stars 3 forks source link

Should not sys.exit, this exits pytest #10

Closed ipwnponies closed 5 years ago

ipwnponies commented 5 years ago

https://github.com/ipwnponies/pytest-antilru/blob/a78af3da55c6b71e1c2172c3368c70f6f7d93713/pytest_antilru/main.py#L18

What's wrong

If lru_cache is not found, this plugin will make pytest immediately terminate.

This means the user is not even using lru_cache. This can be an unnecessary installation of this plugin or a test environment misconfiguration.

This doesn't apply to python 3, functools.lru_cache is in the stdlib and always available.

Proposed Solution

We should use pytest calls to set a failure, so that pytest can report it as such.

Note: If there's a request for warning instead of failing, we can make the plugin noop. Probably if a package is using some python testing template but doesn't need this plugin. But this seems like supporting workaround instead, not in the scope of this ticket.