pytest-lazy-fixture
pytest-lazy-fixture copied to clipboard
fix issue #24: LazyFixture only resolved when used directly, ...
Hello the PR has following motivation:
- Fix for https://github.com/TvoroG/pytest-lazy-fixture/issues/24.
Usage:
import pytest
@pytest.fixture(params=[
dict(one=1, two=pytest.lazy_fixture('two')),
dict(one=pytest.lazy_fixture('one'), two=2),
dict(one=pytest.lazy_fixture('one'), two=pytest.lazy_fixture('two'))
])
def some(request):
return request.param
@pytest.fixture
def one():
return 1
@pytest.fixture
def two():
return 2
def test_func(some):
assert some == dict(one=1, two=2)
More samples can be found in tests.
-
Extends current syntax for creating list of fixtures:
pytest.lazy_fixture(['one', 'two'])
with more possibilities:
pytest.lazy_fixture('one', 'two') # will create a tuple
pytest.lazy_fixture(one='one', two='two') # will create a dict
Do not hesitate to express your opinion about code and syntax.
Regards, Artyom.
P.S. Как там Казань? Почему творог, а не эчпочмак? :)
Hey! Thanks for pr!
Как там Казань?
Все норм, только чутка холодновато сейчас :)
Hello @TvoroG.
Have you had a chance to review the code? Do you have any comments? Will the PR be merged?
Regards, Artyom.
Hey!
Have you had a chance to review the code?
Forget to send comments :)
Hi @TvoroG and @ArtyomKaltovich,
Is this PR in the works? If not, I'm willing to take over, I really need this kind of functionality.
Hello @elilutsky.
Looking up every collection drammatically slow down the performance of the tests, I've tried to do it optional, but failed :)
You can try it.
What if you could somehow explicitly mark a dictionary, list, ... that it needs to be searched for nested things?
E.g.:
LazyFixtureList(['a', 'b', lazy_fixture('c'), 'd'])
And maybe there a way of adding some optional syntactic sugar, like this
from pytest_lazyfixture import Lazy
Lazy+['a', 'b', lazy_fixture('c'), 'd']
Lazy+{'x': 1, 'y': lazy_fixture('z')}