Skip to content

Commit 144d1d9

Browse files
oliverhaascharettes
authored andcommitted
Fix #62 -- Address crash of system checks with empty migrations directory.
1 parent ad094ed commit 144d1d9

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
1.2.2
2+
=====
3+
4+
:release-date: not-released
5+
6+
- Address crash of system checks when an installed app has an empty
7+
`migrations` directory. (#62)
8+
19
1.2.1
210
=====
311

syzygy/checks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def check_migrations(app_configs, **kwargs):
3030
except ImportError:
3131
# This is not the place to deal with migration issues.
3232
continue
33+
if module.__file__ is None:
34+
# Skip empty migration folders, which can happen
35+
# for example when switching between branches.
36+
continue
3337
directory = os.path.dirname(module.__file__)
3438
migration_names = set()
3539
for name in os.listdir(directory):

tests/test_checks.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@ def test_ambiguous_stage(self):
2929
id="migrations.0001",
3030
),
3131
)
32+
33+
def test_empty_migration_folder(self):
34+
with self.settings(MIGRATION_MODULES={"tests": "tests.test_migrations.empty"}):
35+
checks = run_checks(
36+
app_configs=[apps.get_app_config("tests")], tags={"migrations"}
37+
)
38+
self.assertEqual(len(checks), 0)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)