TvoroG / pytest-lazy-fixture

It helps to use fixtures in pytest.mark.parametrize
MIT License
377 stars 30 forks source link

fix issue #24: LazyFixture only resolved when used directly, ... #40

Open artsiomkaltovich opened 5 years ago

artsiomkaltovich commented 5 years ago

Hello the PR has following motivation:

1) 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.

2) 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. Как там Казань? Почему творог, а не эчпочмак? :)

TvoroG commented 5 years ago

Hey! Thanks for pr!

Как там Казань?

Все норм, только чутка холодновато сейчас :)

artsiomkaltovich commented 5 years ago

Hello @TvoroG.

Have you had a chance to review the code? Do you have any comments? Will the PR be merged?

Regards, Artyom.

TvoroG commented 5 years ago

Hey!

Have you had a chance to review the code?

Forget to send comments :)

elilutsky commented 4 years ago

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.

artsiomkaltovich commented 4 years ago

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.

YannickJadoul commented 4 years ago

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')}
ruslan-korneev commented 7 months ago

Hey, @ArtyomKaltovich 👋🏼, r u gonna finish this issue, or mb you wanna reassign to somebody else?

artsiomkaltovich commented 7 months ago

Hey, @ArtyomKaltovich 👋🏼, r u gonna finish this issue, or mb you wanna reassign to somebody else?

Hello @ruslan-korneev. You can take it if you want.