Skip to content

[Question]: clarification on autouse fixture invocation #1

@AlessandroMiola

Description

@AlessandroMiola

Hi Eric :)
first off, congrats for maintaining such an amazing blog on pytest features. I'm gradually going through all of the posts: they're great!

As for the autouse internals, some doubts did arise. I'd like to ask you whether you could shed some light on the following:

  • at times (see test/test_number_conversions.py or test/test_combining_autouse_with_normal.py etc.) it seems that specifying autouse=True is irrelevant as you would get the test passed as well by omitting it (as long as you pass the fixture to other fixtures or to test functions); said differently, it is not crystal clear (to me) where's the advantage in specifying autouse=True in situations where not explicitly passing the fixture (to other fixtures or to test functions) would eventually lead to a failure

  • if I were to infer the meaning of autouse=True before reading your post, I would have said that it would have helped eliminating the need for manual fixture invocation (which I would have read as the opportunity to avoid manually passing fixtures to test functions or other fixtures) in specific situations; as it doesn't seem to be the case, can you elaborate more on the rationale behind it? Not even the docs do make it clear (to me at least :))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions