Skip to content

Instantly share code, notes, and snippets.

@walkerh
Created January 10, 2018 16:56
Show Gist options
  • Save walkerh/bc7385d0cc3bcb763195fdd644206560 to your computer and use it in GitHub Desktop.
Save walkerh/bc7385d0cc3bcb763195fdd644206560 to your computer and use it in GitHub Desktop.
Demonstrate pytest fixture scoping and parameterization
# 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