Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created June 9, 2021 12:32
Show Gist options
  • Save velotiotech/215a9f8ccd195df722cb15196471834e to your computer and use it in GitHub Desktop.
Save velotiotech/215a9f8ccd195df722cb15196471834e to your computer and use it in GitHub Desktop.
import pytest
from product.models import Category, Product
@pytest.fixture
def category(db) -> Category:
return Category.objects.create(name="Books")
@pytest.fixture
def product_one(db, category):
return Product.objects.create(name="Book 1", category=category)
@pytest.fixture
def product_two(db, category):
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