
from django.test import TestCase


class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(1 + 1, 2)

import datetime

from django.utils import timezone
from django.test import TestCase

from apps.polls.models import Poll

class PollMethodTests(TestCase):

    def test_was_published_recently_with_future_poll(self):
        """
        was_published_recently() should return False for polls whose
        pub_date is in the future
        """
        future_poll = Poll(pub_date=timezone.now() + datetime.timedelta(days=30))
        self.assertEqual(future_poll.was_published_recently(), False)
Create a test to expose the bug
Create a test to expose the bug

+ import datetime
  
+ from django.utils import timezone
  from django.test import TestCase
  
+ from apps.polls.models import Poll
  
- class SimpleTest(TestCase):
+ class PollMethodTests(TestCase):
-     def test_basic_addition(self):
+ 
+     def test_was_published_recently_with_future_poll(self):
          """
-         Tests that 1 + 1 always equals 2.
+         was_published_recently() should return False for polls whose
+         pub_date is in the future
          """
-         self.assertEqual(1 + 1, 2)
- 
+         future_poll = Poll(pub_date=timezone.now() + datetime.timedelta(days=30))
+         self.assertEqual(future_poll.was_published_recently(), False)
Create a test to expose the bug
## Code Before:

from django.test import TestCase


class SimpleTest(TestCase):
    def test_basic_addition(self):
        """
        Tests that 1 + 1 always equals 2.
        """
        self.assertEqual(1 + 1, 2)

## Instruction:
Create a test to expose the bug
## Code After:
import datetime

from django.utils import timezone
from django.test import TestCase

from apps.polls.models import Poll

class PollMethodTests(TestCase):

    def test_was_published_recently_with_future_poll(self):
        """
        was_published_recently() should return False for polls whose
        pub_date is in the future
        """
        future_poll = Poll(pub_date=timezone.now() + datetime.timedelta(days=30))
        self.assertEqual(future_poll.was_published_recently(), False)