diff options
author | Olly Cope <olly@ollycope.com> | 2015-10-03 12:46:05 +0000 |
---|---|---|
committer | Olly Cope <olly@ollycope.com> | 2015-10-03 12:46:05 +0000 |
commit | 513a738720562b5fec2b0f96f5e3c9009162f69f (patch) | |
tree | d05afdf01ef3d5e18d1f48cb3a97349c51ed693c | |
parent | a7bd447de6c6ce166c478ecca2df7aa3051763c6 (diff) | |
download | yoyo-513a738720562b5fec2b0f96f5e3c9009162f69f.tar.gz |
Fix exception when loading post-apply scripts
-rwxr-xr-x | yoyo/migrations.py | 4 | ||||
-rw-r--r-- | yoyo/tests/test_migrations.py | 26 |
2 files changed, 19 insertions, 11 deletions
diff --git a/yoyo/migrations.py b/yoyo/migrations.py index a7d65ae..2296558 100755 --- a/yoyo/migrations.py +++ b/yoyo/migrations.py @@ -268,7 +268,7 @@ def read_migrations(*directories): Return a ``MigrationList`` containing all migrations from ``directory``. """ from yoyo.scripts import newmigration - migrations = [] + migrations = MigrationList() for directory in directories: paths = [os.path.join(directory, path) for path in os.listdir(directory) @@ -291,7 +291,7 @@ def read_migrations(*directories): else: migrations.append(migration) - return MigrationList(migrations) + return migrations class MigrationList(MutableSequence): diff --git a/yoyo/tests/test_migrations.py b/yoyo/tests/test_migrations.py index 2f7e931..5b18196 100644 --- a/yoyo/tests/test_migrations.py +++ b/yoyo/tests/test_migrations.py @@ -212,15 +212,6 @@ def test_migrations_can_import_step_and_group(tmpdir): assert cursor.fetchall() == [(1,)] -@with_migrations(**{newmigration.tempfile_prefix + 'test': ''}) -def test_read_migrations_ignores_yoyo_new_tmp_files(tmpdir): - """ - The yoyo new command creates temporary files in the migrations directory. - These shouldn't be picked up by yoyo apply etc - """ - assert len(read_migrations(tmpdir)) == 0 - - class TestTopologicalSort(object): def get_mock_migrations(self): @@ -314,3 +305,20 @@ class TestAncestorsDescendants(object): assert descendants(self.m4, self.migrations) == set() assert descendants(self.m5, self.migrations) == {self.m4, self.m3, self.m2, self.m1} + + +class TestReadMigrations(object): + + @with_migrations(**{newmigration.tempfile_prefix + 'test': ''}) + def test_it_ignores_yoyo_new_tmp_files(self, tmpdir): + """ + The yoyo new command creates temporary files in the migrations directory. + These shouldn't be picked up by yoyo apply etc + """ + assert len(read_migrations(tmpdir)) == 0 + + @with_migrations(**{'post-apply': '''step('SELECT 1')'''}) + def test_it_loads_post_apply_scripts(self, tmpdir): + migrations = read_migrations(tmpdir) + assert len(migrations) == 0 + assert len(migrations.post_apply) == 1 |