Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix some bad test running under PostgreSQL

  • Loading branch information...
commit 9ef715d256938bd5d2c95a88ce0479aa5e493981 1 parent f343cbf
Andrew Godwin authored

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  tests/migrations/test_operations.py
6  tests/migrations/test_operations.py
... ...
@@ -1,5 +1,6 @@
1 1
 from django.test import TestCase
2 2
 from django.db import connection, models, migrations
  3
+from django.db.transaction import atomic
3 4
 from django.db.utils import IntegrityError
4 5
 from django.db.migrations.state import ProjectState
5 6
 
@@ -38,7 +39,7 @@ def set_up_test_model(self, app_label):
38 39
             "Pony",
39 40
             [
40 41
                 ("id", models.AutoField(primary_key=True)),
41  
-                ("pink", models.BooleanField(default=True)),
  42
+                ("pink", models.IntegerField(default=3)),
42 43
                 ("weight", models.FloatField()),
43 44
             ],
44 45
         )
@@ -232,7 +233,8 @@ def test_alter_unique_together(self):
232 233
             operation.database_forwards("test_alunto", editor, project_state, new_state)
233 234
         cursor.execute("INSERT INTO test_alunto_pony (id, pink, weight) VALUES (1, 1, 1)")
234 235
         with self.assertRaises(IntegrityError):
235  
-            cursor.execute("INSERT INTO test_alunto_pony (id, pink, weight) VALUES (2, 1, 1)")
  236
+            with atomic():
  237
+                cursor.execute("INSERT INTO test_alunto_pony (id, pink, weight) VALUES (2, 1, 1)")
236 238
         cursor.execute("DELETE FROM test_alunto_pony")
237 239
         # And test reversal
238 240
         with connection.schema_editor() as editor:

0 notes on commit 9ef715d

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