Why would a pytest factory as fixture be used over a factory function?
问题 In the py.test docs it describes declaring factory methods as fixtures, like-so: @pytest.fixture def make_foo(): def __make_foo(name): foo = Foo() foo.name = name return foo return __make_foo What are the benefits/tradeoffs of doing this over just defining a make_foo function and using that? I don't understand why it is a fixture. 回答1: Actually, the most important advantage is being able to use other fixtures, and make the dependency injection of pytest work for you. The other advantage is