from django.test import TestCase from mixer.backend.django import mixer from accounts.models import User, UserProfile class UserProfileModelTest(TestCase): def test_string_representation(self): user = mixer.blend(User, username='test') user.save() profile = UserProfile.objects.get(user=user) self.assertEqual(str(profile), str(user.username))