Why pytest.mark.usefixtures?
概要
1.Fixtures are reusable
2.A test/fixture can request more than one fixture at a time
3.Fixtures can be requested more than once per test (return values are cached)
4.Autouse fixtures(fixtures you don’t have to request)
5.Scope: sharing fixtures across classes, modules, packages or session
6.Fixture scopes
7.Dynamic scope
8.Teardown/Cleanup(AKA Fixture finalization)
-yield fixtures
“Yield” fixtures yield instead of return
Handling errors for yield fixture
-Adding finalizers directly
Note on finalizer order
-Finalizers are executed in a first-in-last-out order. For yield fixtures, the first teardown code to run is from the right-most fixture, i.e. the last test parameter.
Fixtures can introspect the requesting test context
Using marks with parametrized fixtures
pytest.param() can be used to apply marks in values sets of parametrized fixtures in the same way that they can be used with @pytest.mark.parametrize.
Citation:
https://docs.pytest.org/en/stable/how-to/fixtures.html
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。