Created
May 14, 2021 10:42
-
-
Save adamchainz/0f3be2663e637fd387bd093920125c17 to your computer and use it in GitHub Desktop.
parameterized-data
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
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