Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix some bad test running under PostgreSQL

  • Loading branch information...
commit 9ef715d256938bd5d2c95a88ce0479aa5e493981 1 parent f343cbf
Andrew Godwin andrewgodwin authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 tests/migrations/test_operations.py
6 tests/migrations/test_operations.py
View
@@ -1,5 +1,6 @@
from django.test import TestCase
from django.db import connection, models, migrations
+from django.db.transaction import atomic
from django.db.utils import IntegrityError
from django.db.migrations.state import ProjectState
@@ -38,7 +39,7 @@ def set_up_test_model(self, app_label):
"Pony",
[
("id", models.AutoField(primary_key=True)),
- ("pink", models.BooleanField(default=True)),
+ ("pink", models.IntegerField(default=3)),
("weight", models.FloatField()),
],
)
@@ -232,7 +233,8 @@ def test_alter_unique_together(self):
operation.database_forwards("test_alunto", editor, project_state, new_state)
cursor.execute("INSERT INTO test_alunto_pony (id, pink, weight) VALUES (1, 1, 1)")
with self.assertRaises(IntegrityError):
- cursor.execute("INSERT INTO test_alunto_pony (id, pink, weight) VALUES (2, 1, 1)")
+ with atomic():
+ cursor.execute("INSERT INTO test_alunto_pony (id, pink, weight) VALUES (2, 1, 1)")
cursor.execute("DELETE FROM test_alunto_pony")
# And test reversal
with connection.schema_editor() as editor:
Please sign in to comment.
Something went wrong with that request. Please try again.