Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using fixture that returns a list of parameters, is it possible? #60

Open
ghost opened this issue Dec 8, 2022 · 1 comment
Open

Using fixture that returns a list of parameters, is it possible? #60

ghost opened this issue Dec 8, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 8, 2022

Here's my fixture:

@fixture
def devices(scope='module');
    with connect(get_all_devices()) as connected_devices:
        yield connected_devices

Here's how I want to use it:

@parametrize('device', devices)
def test_routine(device):
    device.do_something()
    assert device.is_ok()

What I'm doing instead:

def test_routine(subtests, devices):
    for index, device in enumerate(devices):
        with subtests.test(device, i=index):
            device.do_something()
            assert device.is_ok()

Is this possible with lazy fixture or any other method?

@alkimake
Copy link

alkimake commented Mar 7, 2023

i have the exact same issue with parametrized list of fixture. Currently getting the names and dictionary of devices and get the real device inside of the test method.

your solution is somewhat good, but i would choose lazy implementation also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant