From 89f40e36246100df6a11316c31a76712ebc6c501 Mon Sep 17 00:00:00 2001
From: Florian Apolloner <florian@apolloner.eu>
Date: Tue, 26 Feb 2013 09:53:47 +0100
Subject: Merged regressiontests and modeltests into the test root.

---
 tests/initial_sql_regress/sql/simple.sql | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 tests/initial_sql_regress/sql/simple.sql

(limited to 'tests/initial_sql_regress/sql/simple.sql')

diff --git a/tests/initial_sql_regress/sql/simple.sql b/tests/initial_sql_regress/sql/simple.sql
new file mode 100644
index 0000000000..d82f8381af
--- /dev/null
+++ b/tests/initial_sql_regress/sql/simple.sql
@@ -0,0 +1,11 @@
+-- a comment
+INSERT INTO initial_sql_regress_simple (name) VALUES ('John'); -- another comment
+INSERT INTO initial_sql_regress_simple (name) VALUES ('-- Comment Man');
+INSERT INTO initial_sql_regress_simple (name) VALUES ('Paul');
+INSERT INTO
+    initial_sql_regress_simple (name) VALUES ('Ringo');
+INSERT INTO initial_sql_regress_simple (name) VALUES ('George');
+INSERT INTO initial_sql_regress_simple (name) VALUES ('Miles O''Brien');
+INSERT INTO initial_sql_regress_simple (name) VALUES ('Semicolon;Man');
+INSERT INTO initial_sql_regress_simple (name) VALUES ('This line has a Windows line ending');
+
-- 
cgit v1.3


From 34a50e99e80295aa0a8970a775f53c62fe220c5a Mon Sep 17 00:00:00 2001
From: Claude Paroz <claude@2xlibre.net>
Date: Tue, 26 Mar 2013 23:18:03 +0100
Subject: Added regression test for custom SQL containing percents

Refs #3485.
---
 tests/initial_sql_regress/sql/simple.sql |  1 +
 tests/initial_sql_regress/tests.py       | 37 ++++++++++++++++++++++++--------
 2 files changed, 29 insertions(+), 9 deletions(-)

(limited to 'tests/initial_sql_regress/sql/simple.sql')

diff --git a/tests/initial_sql_regress/sql/simple.sql b/tests/initial_sql_regress/sql/simple.sql
index d82f8381af..c3edb11c5a 100644
--- a/tests/initial_sql_regress/sql/simple.sql
+++ b/tests/initial_sql_regress/sql/simple.sql
@@ -7,5 +7,6 @@ INSERT INTO
 INSERT INTO initial_sql_regress_simple (name) VALUES ('George');
 INSERT INTO initial_sql_regress_simple (name) VALUES ('Miles O''Brien');
 INSERT INTO initial_sql_regress_simple (name) VALUES ('Semicolon;Man');
+INSERT INTO initial_sql_regress_simple (name) VALUES ('"100%" of % are not placeholders');
 INSERT INTO initial_sql_regress_simple (name) VALUES ('This line has a Windows line ending');
 
diff --git a/tests/initial_sql_regress/tests.py b/tests/initial_sql_regress/tests.py
index 39d8921061..bd23aab15d 100644
--- a/tests/initial_sql_regress/tests.py
+++ b/tests/initial_sql_regress/tests.py
@@ -2,27 +2,46 @@ from django.core.management.color import no_style
 from django.core.management.sql import custom_sql_for_model
 from django.db import connections, DEFAULT_DB_ALIAS
 from django.test import TestCase
+from django.test.utils import override_settings
 
 from .models import Simple
 
 
 class InitialSQLTests(TestCase):
-    # The format of the included SQL file for this test suite is important.
-    # It must end with a trailing newline in order to test the fix for #2161.
+    """
+    The format of the included SQL file for this test suite is important.
+    It must end with a trailing newline in order to test the fix for #2161.
+    """
 
     def test_initial_sql(self):
-        # As pointed out by #14661, test data loaded by custom SQL
-        # can't be relied upon; as a result, the test framework flushes the
-        # data contents before every test. This test validates that this has
-        # occurred.
+        """
+        As pointed out by #14661, test data loaded by custom SQL
+        can't be relied upon; as a result, the test framework flushes the
+        data contents before every test. This test validates that this has
+        occurred.
+        """
         self.assertEqual(Simple.objects.count(), 0)
 
     def test_custom_sql(self):
-        # Simulate the custom SQL loading by syncdb
+        """
+        Simulate the custom SQL loading by syncdb.
+        """
         connection = connections[DEFAULT_DB_ALIAS]
         custom_sql = custom_sql_for_model(Simple, no_style(), connection)
-        self.assertEqual(len(custom_sql), 8)
+        self.assertEqual(len(custom_sql), 9)
         cursor = connection.cursor()
         for sql in custom_sql:
             cursor.execute(sql)
-        self.assertEqual(Simple.objects.count(), 8)
+        self.assertEqual(Simple.objects.count(), 9)
+        self.assertEqual(
+            Simple.objects.get(name__contains='placeholders').name,
+            '"100%" of % are not placeholders'
+        )
+
+    @override_settings(DEBUG=True)
+    def test_custom_sql_debug(self):
+        """
+        Same test, ensure that CursorDebugWrapper doesn't alter sql loading
+        (#3485).
+        """
+        self.test_custom_sql()
-- 
cgit v1.3

