diff --git a/tests/regressiontests/initial_sql_regress/sql/simple.sql b/tests/regressiontests/initial_sql_regress/sql/simple.sql
index ca9bd40..ef2be49 100644
a
|
b
|
|
1 | | INSERT INTO initial_sql_regress_simple (name) VALUES ('John'); |
| 1 | -- a comment |
| 2 | INSERT INTO initial_sql_regress_simple (name) VALUES ('John'); -- another comment |
| 3 | INSERT INTO initial_sql_regress_simple (name) VALUES ('-- Comment Man'); |
2 | 4 | INSERT INTO initial_sql_regress_simple (name) VALUES ('Paul'); |
3 | 5 | INSERT INTO initial_sql_regress_simple (name) VALUES ('Ringo'); |
4 | 6 | INSERT INTO initial_sql_regress_simple (name) VALUES ('George'); |
diff --git a/tests/regressiontests/initial_sql_regress/tests.py b/tests/regressiontests/initial_sql_regress/tests.py
index 815b75a..03a91cb 100644
a
|
b
|
from .models import Simple
|
4 | 4 | |
5 | 5 | |
6 | 6 | class InitialSQLTests(TestCase): |
7 | | def test_initial_sql(self): |
8 | | # The format of the included SQL file for this test suite is important. |
9 | | # It must end with a trailing newline in order to test the fix for #2161. |
| 7 | # The format of the included SQL file for this test suite is important. |
| 8 | # It must end with a trailing newline in order to test the fix for #2161. |
10 | 9 | |
11 | | # However, as pointed out by #14661, test data loaded by custom SQL |
| 10 | def test_initial_sql(self): |
| 11 | # As pointed out by #14661, test data loaded by custom SQL |
12 | 12 | # can't be relied upon; as a result, the test framework flushes the |
13 | 13 | # data contents before every test. This test validates that this has |
14 | 14 | # occurred. |
15 | 15 | self.assertEqual(Simple.objects.count(), 0) |
| 16 | |
| 17 | def test_custom_sql(self): |
| 18 | from django.core.management.sql import custom_sql_for_model |
| 19 | from django.core.management.color import no_style |
| 20 | from django.db import connections, DEFAULT_DB_ALIAS |
| 21 | |
| 22 | # Simulate the custom SQL loading by syncdb |
| 23 | connection = connections[DEFAULT_DB_ALIAS] |
| 24 | custom_sql = custom_sql_for_model(Simple, no_style(), connection) |
| 25 | self.assertEqual(len(custom_sql), 8) |
| 26 | cursor = connection.cursor() |
| 27 | for sql in custom_sql: |
| 28 | cursor.execute(sql) |
| 29 | self.assertEqual(Simple.objects.count(), 8) |