Created
January 10, 2018 16:56
-
-
Save walkerh/bc7385d0cc3bcb763195fdd644206560 to your computer and use it in GitHub Desktop.
Demonstrate pytest fixture scoping and parameterization
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
# Just run 'pytest' from the directory containing this file. | |
from pytest import fixture | |
def test_a(foo): | |
assert 0, foo | |
def test_b(foo): | |
assert 0, foo | |
@fixture(scope='module', params=['spam', 'eggs']) | |
def foo(tmpdir_factory, request): | |
return next(i), request.param, tmpdir_factory.mktemp('foo') | |
i = iter(['first', 'second', 'third']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment