Skip to content

Instantly share code, notes, and snippets.

@nils-werner
Created April 22, 2015 13:25
Show Gist options
  • Save nils-werner/71164e834d77eb5f7219 to your computer and use it in GitHub Desktop.
Save nils-werner/71164e834d77eb5f7219 to your computer and use it in GitHub Desktop.
Abbreviating stub pytest fixtures
@pytest.fixture(params=(True, False))
def odd(request):
return request.param
@pytest.fixture(params=(1, 2))
def channels(request):
return request.param
@pytest.fixture(params=(16000, 44100))
def samplerate(request):
return request.param
test_something(channels, samplerate, odd):
do_something(channels, samplerate)
whatever(odd)
import pytest
odd = pytest.fixture_from_list((True, False))
channels = pytest.fixture_from_list((1, 2))
samplerate = pytest.fixture_from_list((16000, 44100))
test_something(channels, samplerate, odd):
do_something(channels, samplerate)
whatever(odd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment