Hi all,
I'm having trouble creating a test suite in Django 1.3.
Say I have an installed app in a directory called app_name. One of the files in that directory is foo.py which defines a class named Foo. I want to test that, so I also have a file that directory called foo_test.py which defines a class named FooTest. That file looks like:
import unittest
import foo
class FooTest(unittest.TestCase):
def setUp(self):
self.foo_instance = foo.Foo()
... etc
Now down the line I'll have other test cases in other files, and I'll want to run them all as part of a test suite. So in the same directory app_name I created a file tests.py which will define the suite. At first I defined it like:
import foo_test
from django.test.simple import DjangoTestSuiteRunner
def suite():
runner = DjangoTestSuiteRunner()
return runner.build_suite(['app_name'])
Unfortunately, this fails because calling runner.build_suite(['app_name']) searches app_name for a tests.py file, executes suite(), and this continues recursively until the Python interpreter stops everything for exceeding the maximum recursion depth.
Changing runner.build_suite(['app_name']) to one of the following:
runner.build_suite(['app_name.foo_test'])
runner.build_suite(['app_name.foo_test.FooTest'])
Leads to errors like "ValueError: Test label 'app_name.foo_test' does not refer to a test". And changing it to one of the following:
runner.build_suite(['foo_test'])
runner.build_suite(['foo_test.FooTest'])
Leads to errors like "App with label foo_test could not be found".
I'm kind of out of ideas at this point. Any help would be very much appreciated!
Regards, Mike