pytest-dev / pytest-fixture-tools

Pytest fixture tools
MIT License
38 stars 6 forks source link

Make explicit which fixtures a test use #2

Open taliaga opened 9 years ago

taliaga commented 9 years ago

Moved from https://github.com/pytest-dev/pytest/issues/901.

nicoddemus commented 9 years ago

I think a nice fit would be to create a new command line switch which outputs the collection tree similar to what you see with --collection-only, but annotated with all the fixtures that are enabled for each item as discovered during collection (including autouse fixtures, which seems to be the main use case mentioned by @taliaga):

<Module 'testing/python/raises.py'>
  <Class 'TestRaises'>
    <Instance '()'>
      <Function 'test_raises'> fixtures: testdir
      <Function 'test_raises_exec'> fixtures: testdir
      <Function 'test_raises_syntax_error'> fixtures: testdir
      <Function 'test_raises_function'> fixtures: testdir
      <Function 'test_raises_callable_no_exception'> fixtures: testdir
      <Function 'test_raises_flip_builtin_AssertionError'> fixtures: testdir
      <Function 'test_raises_as_contextmanager'> fixtures: testdir
      <Function 'test_noclass'> fixtures: testdir
      <Function 'test_tuple'> fixtures: testdir

Possibly with different colors for normal fixtures and autouse fixtures.

fruch commented 6 years ago

@nicoddemus maybe #3 kind of answer this one ?