I do this and work terrible well. I can debug it from Komodo, I can set breakpoints, Is FAST (all test is under memory)
#Clase sobre la cual basar los test... import unittest import sys import os SETTINGS_MODULE = 'settings' project_dir = os.path.abspath('../') sys.path.append(os.path.join(project_dir, '..')) sys.path.append("..") sys.path.pop() os.environ['DJANGO_SETTINGS_MODULE'] = 'jhonWeb.settings' from django.conf import settings from django.core import management from django import db from django.contrib.auth.management import create_superuser from django.contrib.auth import models as auth_app from django.db.models import signals from django.db import connection from django.dispatch import dispatcher from jhonWeb.core.models import Country,City,State,Settings from jhonWeb.blogs.models import Blog from jhonWeb.links.models import Link from jhonWeb.multimedia.models import * from jhonWeb.restaurant.models import Restaurant,Bono,RestaurantAddress from jhonWeb.core.install import InstallJhonWeb class BaseTestJhonWeb(unittest.TestCase): def _testSetup(self): pass def setUp(self): # Change Settings settings.DATABASE_NAME = ':memory:' settings.DATABASE_ENGINE = 'sqlite3' # Install Models cursor = connection.cursor() self._set_autocommit(connection) # disable the "create a super user" question try: dispatcher.disconnect(create_superuser, sender=auth_app, signal=signals.post_syncdb) except: pass management.syncdb() # Reload DB module #reload(db) self._testSetup() def _set_autocommit(self, connection): """ Make sure a connection is in autocommit mode. """ if hasattr(connection.connection, "autocommit"): connection.connection.autocommit(True) elif hasattr(connection.connection, "set_isolation_level"): connection.connection.set_isolation_level(0) class BaseTestWithTestData(BaseTestJhonWeb): def _testSetup(self): if hasattr(self,'DataInstalled')==False: # NOTE: This is my custom setup for my application, ignore it if want oSetup=InstallJhonWeb(crearDatos=False) oSetup.EraseAllData() oSetup.RunInstall() Blog(tags='Categoria2\Producto1',userId='b1',title='Blog1',content='*Contenido Blog*').save() Blog(tags='Categoria1\Producto1,Categoria2\Producto2',userId='b2',title='Blog2',content='h2.Contenido Blog').save() Blog(tags='Producto3',userId='b3',title='Blog3',content='-Contenido- Blog').save() Blog(tags='Producto4,Categoria1\Producto5',userId='b4',title='Blog4',content='#Contenido Blog').save() self.DataInstalled = True self.assertEqual(4,Blog.objects.count()) In a specific test: #Probar las clases de restaurantes import unittest from BaseTest import BaseTestWithTestData from jhonWeb.core.models import City class testRestaurant(BaseTestWithTestData): def testBasic(self): lista = Blogs.objects.filter(userId='r1') self.assertEqual(lista.count(),1) restaurante = lista[0] ,... more stuff here --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---