title: How to create a similar to "setUp" method in unittest using pytest fixtures and django
body: <p>I have the code below in my test files and trying to refactor it. I am new to pytest and i am trying to achieve the similar method setUp available with unittest to be able to retrieve the object created in the db to other function instead of repeating the codes.</p>
  <p>In this case I want to reuse <strong>month</strong> from <strong>test_setup</strong> to the other functions.</p>
  <h1>test_models.py</h1>
  <pre><code>@pytest.mark.django_db
  class TestMonth:
      # def test_setup(self):
      #     month = Month.objects.create(name=&quot;january&quot;, slug=&quot;january&quot;)
      #     month.save()
  
      def test_month_model_save(self):
          month = Month.objects.create(name=&quot;january&quot;, slug=&quot;january&quot;)
          month.save()
          assert month.name == &quot;january&quot;
          assert month.name == month.slug
  
      def test_month_get_absolute_url(self, client):
          month = Month.objects.create(name=&quot;january&quot;, slug=&quot;january&quot;)
          month.save()
          response = client.get(reverse('core:month_detail', kwargs={'slug': month.slug}))
          assert response.status_code == 200
  
  </code></pre>
  <p>I would appreciate the help.</p>