Ticket #3485: initial_sql_regress_models.diff

File initial_sql_regress_models.diff, 1.4 KB (added by Craig Ogg <cogg@…>, 17 years ago)

Additional test added to trunk/tests/regressiontests/initial_sql_regress/models.py

  • models.py

     
    77class Simple(models.Model):
    88    name = models.CharField(max_length = 50)
    99
    10 __test__ = {'API_TESTS':""}
     10class Simple2(models.Model):
     11    name = models.CharField(max_length = 50)
    1112
    12 # NOTE: The format of the included SQL file for this test suite is important.
     13    def __unicode__(self):
     14        return self.name
     15
     16
     17__test__ = {'API_TESTS':"""
     18# Syncdb introduces these records from custom SQL.
     19>>> from django.conf import settings
     20>>> from django.core import management
     21>>> from django.db.models import get_app
     22
     23# Error only occurs when adding the SQL query to the debug output
     24# so need to be in debug mode
     25>>> _debug_setting_old = settings.DEBUG
     26>>> settings.DEBUG = True
     27
     28# Reset the database representation of this app in a way that will
     29# trigger initial SQL loading while in DEBUG mode
     30>>> management.reset(get_app('initial_sql_regress'), interactive=False)
     31
     32>>> Simple2.objects.all()
     33[<Simple2: John & Kathy>, <Simple2: Miles O'Brien>, <Simple2: "100%" of % are not placeholders>]
     34
     35# Restore DEBUG setting
     36>>> settings.DEBUG = _debug_setting_old
     37"""}
     38
     39
     40# NOTE: The format of simple.sql file for this test suite is important.
    1341# It must end with a trailing newline in order to test the fix for #2161.
Back to Top