Nicolas Straub
Nicolas Straub

Reputation: 3411

django testrunner not running my tests

I've got the following tests.py file:

from django.test import TestCase
from lxml import etree
import tempfile

import utils

class CreateSurveyFromCsvTextTests(TestCase):

    def parsesSurveyPassedInAsCsvAndReturnsXmlRepresentation(self):
        text = """"survey",,,,,
                ,"name","type","label","hint","required"
                ,"gps","geopoint","Record your current location",,"false"
                ,"start","start",,,
                ,"end","end",,,
                "settings",
                ,"form_title"
                ,"New survey" """

        xml = create_survey_from_csv_text(text)

        lxml.fromstring(xml)

when I run my module with python manage.py test, the output is

Ran 0 tests in 0.000s

I know the runner is picking up the file because if I make an invalid import it throws an error.

Why is the test not being called?

Upvotes: 0

Views: 116

Answers (1)

Simeon Visser
Simeon Visser

Reputation: 122506

The name of the test methods need to start with test_. This allows the class to have both test methods and helper methods that you may write as well.

Hence you should rename your method to test_parsesSurveyPassedInAsCsvAndReturnsXmlRepresentation (and perhaps shorten the name too).

Upvotes: 1

Related Questions