lazy-fixture-0.5.2: function fixture runs before module fixture
See original GitHub issuepytest-5.1.3 lazy-fixture-0.5.2
Example:
import pytest
from pytest_lazyfixture import lazy_fixture
@pytest.fixture(scope="module")
def module_fixture():
print('using module fixture')
@pytest.fixture
def fixture1():
print("using fixture1")
@pytest.fixture
def fixture2():
print("using fixture2")
@pytest.mark.usefixtures("module_fixture")
@pytest.mark.parametrize("fixt", [lazy_fixture("fixture1"), lazy_fixture("fixture2")])
def test_test(fixt):
pass
output
smoke/test_test.py::test_test[fixt0] using fixture1
using module fixture
PASSED
smoke/test_test.py::test_test[fixt1] using fixture2
PASSED
There is strange order - fixture1, module fixture, fixture2
Same example without using lazy_fixture:
@pytest.mark.usefixtures("module_fixture")
def test_test1(fixture1):
pass
@pytest.mark.usefixtures("module_fixture")
def test_test2(fixture2):
pass
output:
smoke/test_test.py::test_test1 using module fixture
using fixture1
PASSED
smoke/test_test.py::test_test2 using fixture2
PASSED
Executing order looks as designed - module fixture, fixture1, fixture2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to use fixtures — pytest documentation
Once pytest finds them, it runs those fixtures, captures what they returned (if anything), and passes those objects into the test function as...
Read more >setup_* executed before all fixtures · Issue #517 · pytest-dev ...
Another way to put it: Are there any reasons to not run fixtures before all ... in the same file/module as the test...
Read more >How can i run the fixture before other fixtures? pytest python3.7
I want to run the fixture before other fixtures. How can I set one function to run before all the function in "conftest.py"?...
Read more >pytest fixtures: explicit, modular, scalable
fixtures have explicit names and are activated by declaring their use from test functions, modules, classes or whole projects. fixtures are implemented in...
Read more >pytest fixtures easy example | pythontest - Brian Okken
Module level fixtures don't work if you just want to run the one function that doesn't use the resource. I then presented class...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks, @lenvk! I’ll look at it.
Yep, it’s time)