@@ -4360,23 +4360,43 @@ def test_makemigrate_01(self):
4360
4360
migration = import_migration (
4361
4361
settings .TEST_MIGRATION_DIR / "0001_initial.py"
4362
4362
)
4363
- self .assertIsInstance (migration .operations [1 ], migrations .AddConstraint )
4364
- self .assertEqual (
4365
- migration .operations [1 ].constraint .check , Q (int_enum__in = [0 , 1 , 2 ])
4366
- )
4367
- self .assertEqual (
4368
- migration .operations [1 ].constraint .name ,
4369
- "tests_edit_tests_MigrationTester_int_enum_IntEnum" ,
4370
- )
4371
- self .assertIsInstance (migration .operations [2 ], migrations .AddConstraint )
4372
- self .assertEqual (
4373
- migration .operations [2 ].constraint .check ,
4374
- Q (color__in = ["R" , "G" , "B" , "K" ]),
4375
- )
4376
- self .assertEqual (
4377
- migration .operations [2 ].constraint .name ,
4378
- "tests_edit_tests_MigrationTester_color_Color" ,
4379
- )
4363
+ if django_version >= (5 , 1 ):
4364
+ self .assertIsInstance (migration .operations [0 ], migrations .CreateModel )
4365
+ self .assertEqual (len (migration .operations [0 ].options ['constraints' ]), 2 )
4366
+ self .assertEqual (
4367
+ migration .operations [0 ].options ['constraints' ][0 ].name ,
4368
+ "tests_edit_tests_MigrationTester_int_enum_IntEnum" ,
4369
+ )
4370
+ self .assertEqual (
4371
+ migration .operations [0 ].options ['constraints' ][0 ].check ,
4372
+ Q (int_enum__in = [0 , 1 , 2 ])
4373
+ )
4374
+ self .assertEqual (
4375
+ migration .operations [0 ].options ['constraints' ][1 ].name ,
4376
+ "tests_edit_tests_MigrationTester_color_Color" ,
4377
+ )
4378
+ self .assertEqual (
4379
+ migration .operations [0 ].options ['constraints' ][1 ].check ,
4380
+ Q (color__in = ["R" , "G" , "B" , "K" ])
4381
+ )
4382
+ else :
4383
+ self .assertIsInstance (migration .operations [1 ], migrations .AddConstraint )
4384
+ self .assertEqual (
4385
+ migration .operations [1 ].constraint .check , Q (int_enum__in = [0 , 1 , 2 ])
4386
+ )
4387
+ self .assertEqual (
4388
+ migration .operations [1 ].constraint .name ,
4389
+ "tests_edit_tests_MigrationTester_int_enum_IntEnum" ,
4390
+ )
4391
+ self .assertIsInstance (migration .operations [2 ], migrations .AddConstraint )
4392
+ self .assertEqual (
4393
+ migration .operations [2 ].constraint .check ,
4394
+ Q (color__in = ["R" , "G" , "B" , "K" ]),
4395
+ )
4396
+ self .assertEqual (
4397
+ migration .operations [2 ].constraint .name ,
4398
+ "tests_edit_tests_MigrationTester_color_Color" ,
4399
+ )
4380
4400
4381
4401
def test_makemigrate_02 (self ):
4382
4402
import shutil
0 commit comments