Loading tests/migrations/test_operations.py +4 −2 Original line number Diff line number Diff line 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 Loading Loading @@ -38,7 +39,7 @@ class OperationTests(TestCase): "Pony", [ ("id", models.AutoField(primary_key=True)), ("pink", models.BooleanField(default=True)), ("pink", models.IntegerField(default=3)), ("weight", models.FloatField()), ], ) Loading Loading @@ -232,6 +233,7 @@ class OperationTests(TestCase): 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): 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 Loading Loading
tests/migrations/test_operations.py +4 −2 Original line number Diff line number Diff line 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 Loading Loading @@ -38,7 +39,7 @@ class OperationTests(TestCase): "Pony", [ ("id", models.AutoField(primary_key=True)), ("pink", models.BooleanField(default=True)), ("pink", models.IntegerField(default=3)), ("weight", models.FloatField()), ], ) Loading Loading @@ -232,6 +233,7 @@ class OperationTests(TestCase): 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): 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 Loading