From 6cdc98c5a123a961b7ff4b61a7b2c5fe3cc69d99 Mon Sep 17 00:00:00 2001 From: Sebastian S Date: Thu, 2 May 2019 18:55:21 +0200 Subject: [PATCH] migrations: Teach MigrationTests about existing duplicate migration numbers --- t/unit/test_models.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/t/unit/test_models.py b/t/unit/test_models.py index 2aecc980..c96b366a 100644 --- a/t/unit/test_models.py +++ b/t/unit/test_models.py @@ -12,7 +12,7 @@ class MigrationTests(TestCase): - def test_no_duplicate_migration_numbers(self): + def test_no_future_duplicate_migration_numbers(self): """Verify no duplicate migration numbers. Migration files with the same number can cause issues with @@ -20,9 +20,15 @@ def test_no_duplicate_migration_numbers(self): """ path = os.path.dirname(beat_migrations.__file__) files = [f[:4] for f in os.listdir(path) if f.endswith('.py')] + expected_duplicates = [ + (3, '0006'), + ] + duplicates_extra = sum(count - 1 for count, _ in expected_duplicates) + duplicates_numbers = [number for _, number in expected_duplicates] self.assertEqual( - len(files), len(set(files)), - msg='Detected migration files with the same migration number') + len(files), len(set(files)) + duplicates_extra, + msg=('Detected migration files with the same migration number' + ' (besides {})'.format(' and '.join(duplicates_numbers)))) def test_models_match_migrations(self): """Make sure that no model changes exist.