Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 9, 2021 12:30
Show Gist options
  • Save velotiotech/bdfb6498cd6fb7a5f8a6325934d3f5e4 to your computer and use it in GitHub Desktop.
Save velotiotech/bdfb6498cd6fb7a5f8a6325934d3f5e4 to your computer and use it in GitHub Desktop.
import pytest
from product.models import Category, Product
@pytest.fixture
def product_one(db):
category = Category.objects.create(name="Books")
return Product.objects.create(name="Book 1", category=category)
@pytest.fixture
def product_two(db):
category = Category.objects.create(name="Books")
return Product.objects.create(name="Book 2", category=category)
def test_two_different_books_create(product_one, product_two):
assert product_one.pk != product_two.pk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment