from django.test import TestCase
from django.conf import settings
from django.db.models.loading import load_app
from django.core.management import call_command
from _fixture import fixture

APP_NAME = 'eventtools.tests.eventtools_testapp'

class TestCaseWithApp(TestCase):

    """Make sure to call super(..).setUp and tearDown on subclasses"""
    
    def setUp(self):
        self.__class__.__module__ = self.__class__.__name__

        self.old_INSTALLED_APPS = settings.INSTALLED_APPS
        settings.INSTALLED_APPS += [APP_NAME]
        self._old_root_urlconf = settings.ROOT_URLCONF
        settings.ROOT_URLCONF = '%s.urls' % APP_NAME
        load_app(APP_NAME)
        call_command('flush', verbosity=0, interactive=False)
        call_command('syncdb', verbosity=0, interactive=False)
        self.ae = self.assertEqual
        fixture(self)
        
    def tearDown(self):
        settings.INSTALLED_APPS = self.old_INSTALLED_APPS
        settings.ROOT_URLCONF = self._old_root_urlconf
@@ -9,28 +9,41 @@
 ngo.
-test import TestCase
+db.models.loading import load_app
 %0Afro
@@ -88,89 +88,164 @@
 ngo.
-db.models.loading import load_app%0Afrom django.core.management import call_command
+core.management import call_command%0Afrom django.template.loaders import app_directories%0Afrom django.template import loader%0Afrom django.test import TestCase%0A
 %0Afro
@@ -924,163 +924,697 @@
     
-fixture(self)%0A        %0A    def tearDown(self):%0A        settings.INSTALLED_APPS = self.old_INSTALLED_APPS%0A        settings.ROOT_URLCONF = self._old_root_urlconf
+self._old_template_loaders = settings.TEMPLATE_LOADERS%0A        loaders = list(settings.TEMPLATE_LOADERS)%0A        try:%0A            loaders.remove('django.template.loaders.filesystem.Loader')%0A            settings.TEMPLATE_LOADERS = loaders%0A            self._refresh_cache()%0A        except ValueError:%0A                pass%0A        fixture(self)%0A        %0A    def tearDown(self):%0A        settings.INSTALLED_APPS = self.old_INSTALLED_APPS%0A        settings.ROOT_URLCONF = self._old_root_urlconf%0A        settings.TEMPLATE_LOADERS = self._old_template_loaders%0A        self._refresh_cache()%0A    %0A    def _refresh_cache(self):%0A        reload(app_directories)%0A        loader.template_source_loaders = None

Disable loading templates from project templates (use only the app ones). Makes all the views tests pass when ran as part of the suite of a larger project like NFSA. (Eventually, eventtools should just use testtools, this functionality is built in there)