Question

I am learning test driven development...

I wrote a test that should fail but it's not...

(env)glitch:ipals nathann$ ./manage.py test npage/
Creating test database for alias 'default'...

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

in npage/ I have tests.py:

from django.test import TestCase
from npage.models import Tip
import datetime


# Example


class TipTester(TestCase):

    def setUp(self):
        print dir(self)
        Tip.objects.create(pk=1,
                           text='Testing',
                           es_text='Probando')

    def tips_in_spanish(self):
        my_tip = Tip.objects.get(pk=1)

        my_tip.set_language('es')

        self.assertEqual(my_tip.text, 'this does not just say \'Probando\'')

What am I doing wrong? I've read this but I still can't figure out what is going wrong here.

Was it helpful?

Solution

Your test functions need to start with test:

def test_tips_in_spanish(self):

Docs here

"When you run your tests, the default behavior of the test utility is to find all the test cases (that is, subclasses of unittest.TestCase) in any file whose name begins with test, automatically build a test suite out of those test cases, and run that suite."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top