Code

Ticket #3485: initial_sql_regress_models.diff

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

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

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