deptry icon indicating copy to clipboard operation
deptry copied to clipboard

Pytest fixtures are wrongly defined as unused

Open gpkc opened this issue 2 years ago • 1 comments

Describe the bug

Packages that are used just as pytest fixtures are wrongly set as unused.

To Reproduce

Steps to reproduce the behavior:

  1. Install pytest-freezer as an example
  2. Create a test that uses that fixture, e.g.
def test_frozen(freezer):
    freezer.move_to("2021-01-01T00:00:00")
  1. Verify that deptry will flag the package.

Expected behavior

The package should not be flagged.

Additional context

I'm not sure if there's a way to do that, or if it's too much outside of the scope of the package. But I'd say this is probably a big enough use case (supporting pytest) that maybe it should be taken into account.

gpkc avatar Dec 24 '23 16:12 gpkc

Development dependencies are not flagged as unused packages, and usually packages that are only meant to be used in dev/tests should be specified in development specific dependencies groups. I don't know about your setup, nor which package manger you use, but if possible, it would be recommended to declare pytest-freezer as a development package in your dependencies.

mkniewallner avatar Mar 23 '24 19:03 mkniewallner