Skip to content

Instantly share code, notes, and snippets.

@adamchainz
Created May 14, 2021 10:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamchainz/0f3be2663e637fd387bd093920125c17 to your computer and use it in GitHub Desktop.
Save adamchainz/0f3be2663e637fd387bd093920125c17 to your computer and use it in GitHub Desktop.
parameterized-data
from copy import deepcopy
import pytest
from django.contrib.auth.models import User
users = [
User(username="a"),
User(username="b"),
]
@pytest.fixture()
def make_users():
original_users = deepcopy(users)
User.objects.bulk_create(users)
users[:] = original_users
@pytest.mark.parametrize("user", users)
def test_thingy(user):
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment