Created
April 22, 2015 13:25
-
-
Save nils-werner/71164e834d77eb5f7219 to your computer and use it in GitHub Desktop.
Abbreviating stub pytest fixtures
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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