Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Tweak a test to avoid hitting a limit with SQLite.

Django cannot delete more than 999 objects at a time with SQLite.

Refs #16426, #16039.
  • Loading branch information...
commit 2875b5dcab23c027d019656b08da8b911bc60711 1 parent c13912a
Aymeric Augustin authored November 23, 2012
15  tests/regressiontests/multiple_database/tests.py
@@ -1912,18 +1912,21 @@ class SyncDBTestCase(TestCase):
1912 1912
 
1913 1913
     def test_syncdb_to_other_database(self):
1914 1914
         """Regression test for #16039: syncdb with --database option."""
1915  
-        count = ContentType.objects.count()
  1915
+        cts = ContentType.objects.using('other').filter(app_label='multiple_database')
  1916
+
  1917
+        count = cts.count()
1916 1918
         self.assertGreater(count, 0)
1917 1919
 
1918  
-        ContentType.objects.using('other').delete()
  1920
+        cts.delete()
1919 1921
         management.call_command('syncdb', verbosity=0, interactive=False,
1920 1922
             load_initial_data=False, database='other')
1921  
-
1922  
-        self.assertEqual(ContentType.objects.using("other").count(), count)
  1923
+        self.assertEqual(cts.count(), count)
1923 1924
 
1924 1925
     def test_syncdb_to_other_database_with_router(self):
1925 1926
         """Regression test for #16039: syncdb with --database option."""
1926  
-        ContentType.objects.using('other').delete()
  1927
+        cts = ContentType.objects.using('other').filter(app_label='multiple_database')
  1928
+
  1929
+        cts.delete()
1927 1930
         try:
1928 1931
             old_routers = router.routers
1929 1932
             router.routers = [SyncOnlyDefaultDatabaseRouter()]
@@ -1932,4 +1935,4 @@ def test_syncdb_to_other_database_with_router(self):
1932 1935
         finally:
1933 1936
             router.routers = old_routers
1934 1937
 
1935  
-        self.assertEqual(ContentType.objects.using("other").count(), 0)
  1938
+        self.assertEqual(cts.count(), 0)

0 notes on commit 2875b5d

Please sign in to comment.
Something went wrong with that request. Please try again.