'объект не имеет атрибута' при выполнении TestCase
Я следую руководству по тестам django, но в моем случае возникает ошибка AttributeError
from django.test import TestCase
from django.urls import reverse
from rest_framework.test import APIClient
class RecipeImageUploadTests(TestCase):
def setUP(self):
self.client = APIClient()
self.user = get_user_model().objects.create_user(
'user@kubousky.com',
'testpass'
)
self.client.force_authenticate(self.user)
self.recipe = sample_recipe(user=self.user)
def tearDown(self):
self.recipe.image.delete()
def test_upload_image_to_recipe(self):
"""Test uploading an image to recipe"""
url = image_upload_url(self.recipe.id)
Ошибка относится к "self.recipe" говорит: объект 'RecipeImageUploadTests' не имеет атрибута 'recipe'
В документации не так много информации о setUP(). Интересно, почему я могу установить self.user, а не любой другой атрибут