BryanWheelock
BryanWheelock

Reputation: 12254

Why is Django testrunner not finding the tests I created?

I had been trying to add tests to a project I'm working on.

The tests are in forum/tests/

When I run manage.py test it doesn't find any of the tests I created, on the tests in Django 1.2

I started with all my tests in their own package but have simplified down to just being in my tests.py file. The current tests.py looks like:

from django.test.client import Client  
from django.test import TestCase  
from utils import *   
from forum.models import *  
from forum import auth  

class ForumTestCase(TestCase):  
    def test_root_page(self):  
        response = self.client.get('/')  
        self.assertEqual(response.status_code, 200)  

    def test_signin_page(self):  
        response = self.client.get("/account/signin/")  
        self.assertEqual(response.status_code, 200)  

I'm sure I am missing something very basic and obvious but I just can't work out what. Any ideas?

INSTALLED_APPS = (  
    'django.contrib.auth',  
    'django.contrib.contenttypes',  
    'django.contrib.sessions',  
    'django.contrib.sites',  
    'django.contrib.admin',  
    'django.contrib.humanize',  
    'forum',  
    'django_authopenid',  
)  

Why would Django testrunner not be finding the tests I created?

The tests are at forum/tests/:

__init__.py
forum/tests/test_views.py  
forum/tests/test_models.py

I also have a __init__.py file in the directory.

Upvotes: 3

Views: 1016

Answers (1)

Davor Lucic
Davor Lucic

Reputation: 29420

As noted in the comment, Django 1.6 introduced backwards-incompatibility with discovery of tests in any test module.

Before Django 1.6, one would have to do the following:

Create file named __init__.py in

forum/tests/__init__.py

And import all test from other moduls inside it.

from test_views import SomeTestCase
from test_models import SomeOtherTestCase

Upvotes: 7

Related Questions