title: IntegrityError: duplicate key value in django unit test
body: <p>I am trying to run the following unit test for my django project:</p>
  
  <pre><code>from django.test import TestCase
  from django.contrib.auth.models import User
  from CarbonEmissions import models
  
  class DbTest(TestCase):
      #is called before each test case (e.g test_insertingUserProfiles)
      def setUp(self):
          self.user = User.objects.create(username='ppoliani')
          self.userProfile = models.UserProfile.objects.create(user=self.user, title='Mr', type='student', occupation='student')
  
      def test_insertingUserProfiles(self):
          """
              Testing the insertion of user profiles into our datbase 
          """
          self.assertEqual(self.user.get_profile().title,'Mr')
  
      #is called after each test case (e.g test_insertingUserProfiles)
      def tearDown(self):
          self.user.delete()
          self.userProfile.delete()
  </code></pre>
  
  <p>The test fails throwing the following error:</p>
  
  <pre><code>IntegrityError: duplicate key value violates unique constraint "CarbonEmissions_userprofile_user_id_key" DETAIL:  Key (user_id)=(1) already exists.
  </code></pre>
  
  <p>I can't understand what's wrong with that code. </p>